[Bug c/106853] compound literal storage duration
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 6 14:41:02 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106853
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In C89 that would be valid scope-wise (but C89 doesn't have compound literals
on the other side), but in C99 and later compound statements like if introduce
a new block scope. So, accessing *p1 is valid during evaluation of the if
condition or during evaluation of the substatements, but not after the compound
statement ends. As the testcase does that, it invokes UB and anything can
happen.
More information about the Gcc-bugs
mailing list