https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119624
Bug ID: 119624
Summary: GCC rejects valid C11 code involving _Generic
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pavel.morozkin at gmail dot com
Target Milestone: ---
Note: this may be a duplicate.
This valid C11 code:
struct s *x, *y;
int i = _Generic(i ? *x : *y, default: 0);
is rejected by GCC (-std=c11 -pedantic -Wall -Wextra):
<source>:2:22: error: invalid use of undefined type 'struct s'
2 | int i = _Generic(i ? *x : *y, default: 0);
| ^
<source>:2:27: error: invalid use of undefined type 'struct s'
2 | int i = _Generic(i ? *x : *y, default: 0);
C11, 6.5.1.1p3:
> The controlling expression of a generic selection is not evaluated.
Keywords / tags: conditional operator, indirection operator, non-modifiable
lvalue, lvalue conversion, non-evaluated expression.