The following code compiled with just -O0 generates bad assembler with undefined label:
int x(int a, int b) { __label__ xlab; __label__ xlab2; void y(int b) { switch (b) { case 1: goto xlab; case 2: goto xlab; } } a = a + 2; y (b); xlab:; return a; xlab2:; a++; return a; } main (int ac) { int i; if ((i=x (1, ac), printf("%d\n",i), i) != 2 + ac) abort (); exit (0); } The assembler failure looks like: Undefined first referenced symbol in file .LL9 /var/tmp//ccLPhTcj.o ld: fatal: Symbol referencing errors. No output written to a.out The t04.nested tree already looks bad: ---------------------------------- y (b) { voidD.28 *[3] * D.1136; voidD.28 *[3] * D.1138; switch (bD.1124) { case 1: goto <D1127>; case 2: goto <D1128>; default : goto <D1131>; } <D1127>:; D.1136 = &CHAIN.1D.1135->__nl_goto_bufD.1133; __builtin_nonlocal_goto (&<D1132>, D.1136); <D1128>:; D.1138 = &CHAIN.1D.1135->__nl_goto_bufD.1133; __builtin_nonlocal_goto (&<D1137>, D.1138); <D1131>:; } x (a, b) { struct FRAME.x FRAME.0D.1134; intD.0 D.1129; voidD.28 xlabD.1122 = <<< error >>>; voidD.28 xlab2D.1123 = <<< error >>>; static voidD.28 yD.1125 (intD.0); aD.1118 = aD.1118 + 2; y (bD.1119) [static-chain: &FRAME.0D.1134]; goto xlabD.1122; <D1137>: [non-local]; xlabD.1122:; D.1129 = aD.1118; return D.1129; xlab2D.1123:; aD.1118 = aD.1118 + 1; D.1129 = aD.1118; return D.1129; } ---------------------------------- The line with problems: __builtin_nonlocal_goto (&<D1132>, D.1136); The reference to &<D1132> is a reference to non-existent label. This problem can be reproduced on all 4.0.* versions and 4.1-20050924 as well. The versions 3.x are ok. I think all hardware platforms may be affected. Alex. -- Summary: nonlocal goto from nested function gets 'undefined symbol' in assembler Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: translation AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alexey dot starovoytov at sun dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: sparc-sun-solaris2.* GCC host triplet: sparc-sun-solaris2.* GCC target triplet: sparc-sun-solaris2.* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24135