https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113215
Bug ID: 113215 Summary: gimple FE can't handle static local variable with initializer Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- The following testcase is accepted: int __GIMPLE (ssa) f () { static int x; __BB(2): return 1; } but adding an initializer to the static variable, it gets rejected: $ cat > t.c int __GIMPLE (ssa) f () { static int x = 1; __BB(2): return 1; } $ gcc/xgcc -B gcc -c -fgimple t.c t.c: In function ‘f’: t.c:4:18: error: expected ‘;’ before ‘=’ token 4 | static int x = 1; | ^ t.c: At top level: t.c:5:10: error: expected declaration specifiers or ‘...’ before numeric constant 5 | __BB(2): | ^ t.c:7:1: error: expected identifier or ‘(’ before ‘}’ token 7 | } | ^ such IL can be generated by dumping optimized GIMPLE as seen e.g. with the following testcase: $ cat t2.c int f() { static int x = 1; return x; } $ gcc/xgcc -B gcc -c t2.c -fdump-tree-optimized-gimple=- int __GIMPLE (ssa) f () { static int x = 1; int D_4434; int _2; __BB(2): _2 = x; goto __BB3; __BB(3): L0: return _2; }