On Wed, Mar 09, 2016 at 04:20:24PM +0100, Marek Polacek wrote: > --- gcc/testsuite/gcc.dg/nested-func-10.c > +++ gcc/testsuite/gcc.dg/nested-func-10.c > @@ -0,0 +1,49 @@ > +/* PR c/70093 */ > +/* { dg-do compile } */ > +/* { dg-options "" } */ > + > +void > +foo (int n) > +{ > + struct S { int a[n]; }; > + > + struct S __attribute__((noreturn)) > + fn (void) > + { > + __builtin_abort (); > + } > + > + auto struct S __attribute__((noreturn)) > + fn2 (void) > + { > + __builtin_abort (); > + } > + > + switch (n) > + { > + case 42:; > + struct S x; > + fn (); > + fn2 (); > + x = fn (); > + > + if (x.a[0] != 42) > + __builtin_abort (); > + > + if (fn ().a[0] != 42) > + __builtin_abort (); > + > + __typeof__ (fn ()) *p = &x; > + if (p->a[0] != 42) > + __builtin_abort (); > + > + if (fn2 ().a[0] != 42) > + __builtin_abort ();
No, I meant: switch (n) { struct S x; case 1: fn (); break; case 2: fn2 (); break; case 3: x = fn (); if (x.a[0] != 42) __builtin_abort (); break; case 4: if (fn ().a[0] != 42) __builtin_abort (); break; ... The reason is that anything after a noreturn call can be optimized away shortly afterwards. Perhaps you want __attribute__((noinline, noclone)) on the function too just in case (I know you haven't included -O*). Otherwise LGTM. Jakub