3 ms·
That one does not work with g++ and actually does not produce a warning with -Wall without optimisations. It makes me wonder if that's actually undefined behav
by simias 14y ago
That one does not work with g++ and actually does not produce a warning with -Wall without optimisations.
It makes me wonder if that's actually undefined behaviour in C++, because unlike the example in the fine article this time the behaviour of the program does not depend on the (undefined) value of b. Or maybe it's just g++ being clever.
- JamesLeonis 14y agoThere is plenty of undefined behavior in C++ [1]. It is important to understand that these aren't bugs in a particular compiler, but deliberate definitions in the standard itself to give compiler writers leeway in their implementations. Amusingly, that means "undefined behavior" is explicitly defined in the standard. http://stackoverflow.com/a/367662/712512 http://stackoverflow.com/a/367662/712512