https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117796
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #10 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Daniel Starke from comment #8)
> (In reply to Andrew Pinski from comment #7)
> > (In reply to Daniel Starke from comment #6)
> > > That means this is considered to be valid C code?
> > So you are using too old ncurses.
>
> Thank you for the research.
> I just wanted to have a confirmation that the code in my original message is
> indeed considered to be valid C code.
C23 sect 6.9 p3:
Moreover, if an identifier declared with internal linkage is used in an
expression there shall be exactly one external definition for the identifier in
the translation unit, unless it is:
— part of the operand of a sizeof operator whose result is an integer constant;
— part of the operand of an alignof operator whose result is an integer
constant;
— or, part of the operand of any typeof operator whose result is not a variably
modified type.
And sect 4 p2:
If a "shall" or "shall not" requirement that appears outside of a constraint or
runtime-constraint is violated, the behavior is undefined.
Thus the behavior is undefined and the compiler can do anything.