Closed meithecatte closed 2 months ago
Ah, good catch - I believe you're right, this is undefined.
It looks like this UB isn't detected by -Wuninitialized
in either GCC or Clang, by -fanalyzer
in GCC, or by Clang's Memory Sanitizer. I think it would be worth filing issues against GCC and Clang for those false negatives; would you like to file those or should I?
I'm not interested in handling the upstream reports, but feel free to drop the links here once you get to it.
The test, as currently written, requires that variables stay alive even outside of the block they are declared in:
See:
Thus, after
goto first_if;
, the lifetime ofint a
begins anew, and its value is not initialized when it is read (which is UB due to 6.3.2.1.2).