When the Debugger Lies
Thread
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
When the Debugger Lies
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
Loren_SL · · focus · HN ↗
LoganDark · · focus · HN ↗
StilesCrisis · · focus · HN ↗
LoganDark · · focus · HN ↗
VorpalWay · · focus · HN ↗
Trying UBSAN and ASAN might have been worth it. I don't think comparing debug and release builds would have helped: could be buggy optimisations or UB in your code regardless of what the outcome of that test was.
LoganDark · · focus · HN ↗
throw324523 · · focus · HN ↗
1. You check in both places in code in the debugger that the address of the field matches. (Maybe the object is at the same address, but due to some build system level ifdef mismatch, you effectively get different struct definitions in different places or something like that.)
2. You add a breakpoint inside the procedure and outside it.
3. When the breakpoint inside is hit, you add a watchpoint at the address of the field. Continue. See if the watchpoint gets hit before reaching the second breakpoint.
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.
LoganDark · · focus · HN ↗
Brian_K_White · · focus · HN ↗
Was it ever even theoretically under any circumstances for any reason intended to be able to write a stack of functions with no returns that just fall into each other like assembly? I can't believe it.
So it seems like something even the very first compiler could have cought right in an early parser pass or stage.
But I also decline to believe I have a better idea about something than K or R, so there must be a non-triviality I don't see.
jcranmer · · focus · HN ↗
The issue is that there is a contingent of users who complains about cases where the return dynamically can't be hit but that isn't obvious statically. Consider something like this:
Should this be required to diagnose? That's the sticking point.VorpalWay · · focus · HN ↗
If an underlying type is specified, then it should error since it is legal to have those values (unless the whole range of the underlying type is covered by the cases.
Again, that is what would be sensible from a C++ perspective, I don't know if C differs here.
throw324523 · · focus · HN ↗
In C it is not UB for an enum to have an integer value that does not correspond to any listed enumeration constants.
hn_go_brrrrr · · focus · HN ↗
gpderetta · · focus · HN ↗
gpderetta · · focus · HN ↗
StilesCrisis · · focus · HN ↗
keel_dev · · focus · HN ↗
[dead]
zavec · · focus · HN ↗
pletnes · · focus · HN ↗
sharktheone · · focus · HN ↗