This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/28342] New: undefined symbol [local label] for goto from nested function [SPARC]
- From: "markosc at interia dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jul 2006 14:15:22 -0000
- Subject: [Bug target/28342] New: undefined symbol [local label] for goto from nested function [SPARC]
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
If there are two goto's that exit from nested functions and go to the same
label in main function, gcc generates references to two different labels, but
generates only one label to jump to. Result is undefined symbol and linking
error. This happens on both SPARC and SPARC64, both -O0 and -O3. However, x86
version works fine.
$ cat xb.c
int bar();
extern int en;
int foo ( ) {
__label__ err;
int res = 0;
void e1 ( ) {
res = -1;
en = 1;
goto err;
}
void e2 ( ) {
res = -1;
en = 2;
goto err;
}
while (1) {
switch (bar()) {
case 1:
e1();
case 2:
e2();
case 3:
goto breakw;
case 4:
res++;
}
continue;
breakw:
break;
}
err:
return res;
}
$ sparc64-elf64-linux-gcc -m32 -c xb.c -o xb.o
$ sparc64-elf64-linux-nm xb.o
U bar
0000011c t e1.1118
000000d8 t e2.1120
U en
00000000 T foo
U .LL17
The problem also happens [though with different label name] for -m64 and/or
-O3.
The workaround is to reduce number of outside goto's per target label to 1,
either by throwing some goto's away, or declaring multiple labels in the target
place, having only one goto to each of them.
--
Summary: undefined symbol [local label] for goto from nested
function [SPARC]
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: markosc at interia dot pl
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sparc64-elf64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28342