Once upon a time I had to figure out an issue where I forgot a `return` statement at the end of a non-`void` function, so the C++ compiler happily omitted both RETs for some reason and let the program go straight into illegal instructions. That was fun to debug (not fun, I practically had to single-step through the entire program) because every time this happened the debugger was incredibly confused about what the fuck was going on and nothing made any sense.
It makes no sense to me that C and C++ didn't require a diagnostic for this, rather you hit UB.
I know that at least modern GCC and Clang will warn and/or error for this (not sure which as I use -Werror), but still, this is pointless UB to have.
And no, in this case I don't buy that a C90 compiler would have been unable to check this.
In some cases it's easy to diagnose, but in others it amounts to the halting problem, so it makes sense that the requirements are loose. Like many things, the standards body considers it a "quality of implementation" issue for compilers to be friendly.
LoganDark · · focus · HN ↗
VorpalWay · · focus · HN ↗
I know that at least modern GCC and Clang will warn and/or error for this (not sure which as I use -Werror), but still, this is pointless UB to have.
And no, in this case I don't buy that a C90 compiler would have been unable to check this.
StilesCrisis · · focus · HN ↗