In a C++ pgm, I have code that looks like
int expectedNewValue = pCellScanData->WLToggle(iWL);
where pCellScanData
is a class and WLToggle
is a member function of that class. Due to a programming error, I invoked this code with pCellScanData
0 (i e, nullptr
), and it did not give a runtime error in a debug (unoptimized) build. The function WLToggle
did not attempt to access any data members of the class. It is not a static member.
Is this behavior expected, or allowed by the C++ standard? Even if it is, I would expect the debug build to at least warn about this suspicious condition.
Using Visual Studio 2015 update 3 under 64-bit Windows 7.
UPDATE: I am asking two questions: (1) What does the current C++ standard say? This is addressed in the referred "duplicate" question, but using the standard in force at the time (6 years ago). (2) Why does Visual Studio debug runtime not give a warning or error for this undefined behavior?