Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Here's the code in InterestResultPolicy.hpp:
namespace apache { namespace geode { namespace client { /** * @class InterestResultPolicy InterestResultPolicy.hpp * Policy class for interest result. */ class APACHE_GEODE_EXPORT InterestResultPolicy { // public static methods public: static char nextOrdinal; static InterestResultPolicy NONE; static InterestResultPolicy KEYS; static InterestResultPolicy KEYS_VALUES; char ordinal; char getOrdinal() { return ordinal; } private: InterestResultPolicy() { ordinal = nextOrdinal++; } };
All the statics are initialized in InterestResultPolicy.cpp, with nextOrdinal set to 0. Thus, most of the time, the InterestResultPolicy instances NONE, KEYS, and KEYS_VALUES are assigned 1, 2, and 3, respectively. The Geode wire protocol most likely depends on these being fixed values, but the code as written relies on initialization order to get the correct values. Initialization order is undefined behavior, and compiler dependent. These need to be explicitly initialized, NONE KEYS and KEYS_VALUES should be members of an enum class rather than object instances, etc.