https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68939
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |openmp, wrong-code --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Adding openmp keyword, so that it not forgotten by me, but I see various other issues. E.g. on the following testcase, with -W -Wall and foo2 ifdefed out I see: pr68939.C: In function ‘void foo(int)’: pr68939.C:16:10: warning: ‘<anonymous>’ may be used uninitialized in this function [-Wmaybe-uninitialized] T1 b; ^ (and with foo2 not ifdefed out a warning in foo2 only, not in foo, strange), and the gimple dump shows that the temporaries for the VLA type are only initialized in the lexical block containing the a variable, but not the other one: int bar (void); void baz (int *, long); void foo (int x) { typedef int T1[bar () + x]; if (x == 6) { T1 a; a[0] = 8; a[bar () + 5] = 9; baz (a, sizeof (a)); } else if (x == 8) { T1 b; b[0] = 9; b[bar () + 7] = 10; baz (b, sizeof (b)); } } void foo2 (int x) { typedef int T1[bar () + x]; if (x == 6) { T1 buf; T1 &a = buf; a[0] = 8; a[bar () + 5] = 9; baz (a, sizeof (a)); } else if (x == 8) { T1 buf; T1 &b = buf; b[0] = 9; b[bar () + 7] = 10; baz (b, sizeof (b)); } } Bet we need to ensure that for the VLA types and REFERENCE_TYPE to VLAs that they for typedefs they have corresponding DECL_EXPR with TYPE_DECL already at the spot where the type is defined, and for the case in #c0, i.e. a decl with REFERENCE_TYPE to non-typedef VLA type arrange for DECL_EXPR with TYPE_DECL to that VLA type to come before the DECL_EXPR of the VAR_DECL. Note the C FE e.g. on foo above (with foo2 containing C++ only code ifdefed out) emits a DECL_EXPR with TYPE_DECL of T1 and thus it works properly. Jason, any thoughts on this?