c/5866: switch with more that 4 cases get assembler error
David B. Roll 614 575-6666
ndbr@seawolf.att.com
Thu Mar 7 07:56:00 GMT 2002
>Number: 5866
>Category: c
>Synopsis: switch with more that 4 cases get assembler error
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 07 07:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: David B. Roll 614 575-6666
>Release: 3.0.3
>Organization:
>Environment:
System: SunOS seawolf 5.6 Generic_105181-19 sun4u sparc sun4u
Architecture: sun4
host: sparc-sun-solaris2.6
build: sparc-sun-solaris2.6
target: sparc-sun-solaris2.6
configured with: ../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld : (reconfigured) ../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld
>Description:
any C code that has switch with more that 4 cases will fail:
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/3.0.3/specs
Configured with: ../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld : (reconfigured) ../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld
Thread model: posix
gcc version 3.0.3
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/3.0.3/cpp0 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=3 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem=unix -Asystem=svr4 -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc jc.c jc.i
GNU CPP version 3.0.3 (cpplib) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/3.0.3/include
/usr/local/sparc-sun-solaris2.6/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/3.0.3/cc1 -fpreprocessed jc.i -quiet -dumpbase jc.c -version -o jc.s
GNU CPP version 3.0.3 (cpplib) (sparc)
GNU C version 3.0.3 (sparc-sun-solaris2.6)
compiled by GNU C version 3.0.3.
/usr/ccs/bin/as -V -Qy -s -o jc.o jc.s
/usr/ccs/bin/as: WorkShop Compilers 4.X dev 18 Sep 1996
/usr/ccs/bin/as: "jc.s", line 627: error: unknown opcode ".subsection"
/usr/ccs/bin/as: "jc.s", line 627: error: statement syntax
/usr/ccs/bin/as: "jc.s", line 639: error: unknown opcode ".previous"
/usr/ccs/bin/as: "jc.s", line 639: error: statement syntax
jc.s line 627:
.LL71:
ret
restore
.align 4
.subsection -1 #line 627
.align 4
.LL15:
.word .LL5
.word .LL6
.word .LL7
.word .LL8
.word .LL9
.word .LL10
.word .LL11
.word .LL12
.word .LL13
.previous #line 639
.LLfe1:
.size main,.LLfe1-main
.ident "GCC: (GNU) 3.0.3"
>How-To-Repeat:
compile this code:
main(argc,argv)
int argc;
char *argv[];
{
char da[3], mon[3], yr[3];
int julian, day, month, year, priority = atoi(argv[2]);
if(argc != 3) {
printf("\n\nFORMAT due mmddyy x\nmm = month\ndd = day\nyy = year");
printf("\nx = no. of days to add\n\nT R Y A G A I N\n\n");
exit();
}
da[0] = argv[1][2];
da[1] = argv[1][3];
da[2] = '\0';
day = atoi(da);
yr[0] = argv[1][4];
yr[1] = argv[1][5];
yr[2] = '\0';
year = atoi(yr);
if(argv[1][0] == '0') {
switch(argv[1][1]) {
case '1': julian = day;
break;
case '2': julian = 31 + day;
break;
case '3': julian = 59 + day;
break;
case '4': julian = 90 + day;
break;
case '5': julian = 120 + day;
break;
case '6': julian = 151 + day;
break;
case '7': julian = 181 + day;
break;
case '8': julian = 212 + day;
break;
case '9': julian = 243 + day;
break;
default : printf("Screw up\n");
exit();
}
}
}
>Fix:
a work around is rm the switch and replace with series of "else if" but if you
have a lot of portable code to load there is no work around, just a lot of work.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list