During my work on bringing code from windows-only platform to the GNU compiler I noticed some strange behavior with an uninitialized pointer to a vector.
The corresponding code looks like this:
typedef vector<IPeer*> Network;
// [...]
Network* m_network;
// [...]
if (m_network == NULL) // <-- this is the strange part
m_network = new Network();
The marked line is making me sad. After declaring my vector it was NULL when I compiled it on my Windows machine. After moving the code to my Mac using GNU Compiler (I'm compiling on g++-5
with -std=c++11
) my vector doesn't seems to be NULL after declaration anymore. The marked line is skipped.
Is this an c++ standard implementation issue or where does this strange behavior came from?