https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65345

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
Or e.g.

_Atomic int i = 5;
int j = sizeof (i + 1);

which is valid code not involving _Generic.  And, similarly:

_Atomic int i = 5;
int j = sizeof (i = 0);

or

_Atomic int i = 5;
int j = sizeof (++i);

or

_Atomic int i = 5;
int j = sizeof (i--);

This at first suggests (but see below) that the special-case handling of 
atomics on lvalue-to-rvalue conversion, and on assignment / increment / 
decrement / any other cases where creation of temporaries is involved, 
should be disabled when at file scope - either the expression in question 
is in a context such as sizeof or _Generic where its side effects do not 
occur so the special handling is not needed, or an error will occur for 
the expression being non-constant even without the special handling.

Much the same applies at function prototype scope, e.g.:

_Atomic int i = 5;
void f (int a[i + 1]);

(where [i + 1] means the same as [*]).  But in the case of

_Atomic int i = 5;
void f (int a[i = 1]) {}

you have a valid program, where the atomic assignment must be executed on 
function entry (see the pending_sizes handling in c-decl.c).  So to handle 
such cases, maybe the special handling of atomics needs to be partly 
deferred, so that parsing "i = 1" generates some tree for atomic 
assignment and the temporaries only get added at gimplification time.

Reply via email to