Subject: bin/11697: gcc miscompiles some switch statements
To: None <gnats-bugs@gnats.netbsd.org>
From: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
List: netbsd-bugs
Date: 12/11/2000 16:03:14
>Number:         11697
>Category:       bin
>Synopsis:       gcc miscompiles some switch statements
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 11 16:03:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Richard Earnshaw
>Release:        NetBSD-current
>Organization:
ARM
	
>Environment:
	
System: NetBSD buzzard.buzzard.freeserve.co.uk 1.5I NetBSD 1.5I (BUZZARD) #216: Sun Nov 19 21:24:48 GMT 2000 rearnsha@buzzard.buzzard.freeserve.co.uk:/usr/src/sys/arch/arm32/compile/BUZZARD arm32


>Description:

	gcc can miscompile some switch tables on the ARM due to the way that 
	the switch statement is represented internally.
	
>How-To-Repeat:
	Try to compile the gen* programs of the latest gcc at -O2: they then
	produce incorrect output and the resulting compiler crashes.
	
>Fix:

	The patch below has been extracted from gcc-2.95.2


begin 664 gcc.patch
M26YD97@Z(&IU;7`N8PH]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"E)#4R!F:6QE
M.B`O8W9S<F]O="]G;G5S<F,O9VYU+V1I<W0O9V-C+VIU;7`N8RQV"G)E=')I
M979I;F<@<F5V:7-I;VX@,2XQ+C$N-`ID:69F("UP("UP("UR,2XQ+C$N-"!J
M=6UP+F,**BHJ(&IU;7`N8PDQ.3DY+S`T+S`V(#$U.C`X.C$S"3$N,2XQ+C0*
M+2TM(&IU;7`N8PDR,#`P+S$R+S$Q(#(S.C0R.C4P"BHJ*BHJ*BHJ*BHJ*BHJ
M*B!J=6UP7V]P=&EM:7IE("AF+"!C<F]S<U]J=6UP+"!N;V]P7VUO=F5S"BHJ
M*B`V-S8L-CDT("HJ*BH*("`)("`@("`@:6YT(&1I9F9?=F5C7W`@/2!'151?
M0T]$12`H4$%45$523B`H:6YS;BDI(#T]($%$1%)?1$E&1E]614,["B`@"2`@
M("`@(&EN="!L96X@/2!85D5#3$5.("AP870L(&1I9F9?=F5C7W`I.PH@(`D@
M("`@("!R='@@9&ES<&%T8V@@/2!P<F5V7W)E86Q?:6YS;B`H:6YS;BD["B`@
M"B`@"2`@("`@(&9O<B`H:2`](#`[(&D@/"!L96X[(&DK*RD*("`)"6EF("A8
M15A0("A85D5#15A0("AP870L(&1I9F9?=F5C7W`L(&DI+"`P*0H@(`D)("`@
M("$](%A%6%`@*%A614-%6%`@*'!A="P@9&EF9E]V96-?<"P@,"DL(#`I*0H@
M(`D)("!B<F5A:SL*("`)("`@("`@:68@*&D@/3T@;&5N"B`@"0D@("8F(&1I
M<W!A=&-H("$](#`*("`)"2`@)B8@1T547T-/1$4@*&1I<W!A=&-H*2`]/2!*
M54U07TE.4TX*("`)"2`@)B8@2E5-4%],04)%3"`H9&ES<&%T8V@I("$](#`*
M(2`)"2`@+RH@1&]N)W0@;65S<R!W:71H(&$@8V%S97-I(&EN<VXN("`J+PHA
M(`D)("`F)B`A*$=%5%]#3T1%("A0051415).("AD:7-P871C:"DI(#T](%-%
M5`HA(`D)("`@("`@("8F("A'151?0T]$12`H4T547U-20R`H4$%45$523B`H
M9&ES<&%T8V@I*2D*(2`)"0D@("`]/2!)1E]42$5.7T5,4T4I*0H@(`D)("`F
M)B!N97AT7W)E86Q?:6YS;B`H2E5-4%],04)%3"`H9&ES<&%T8V@I*2`]/2!I
M;G-N*0H@(`D)>PH@(`D)("!R961I<F5C=%]T86)L96IU;7`@*&1I<W!A=&-H
M+`HM+2T@-C<V+#8Y."`M+2TM"B`@"2`@("`@(&EN="!D:69F7W9E8U]P(#T@
M1T547T-/1$4@*%!!5%1%4DX@*&EN<VXI*2`]/2!!1$127T1)1D9?5D5#.PH@
M(`D@("`@("!I;G0@;&5N(#T@6%9%0TQ%3B`H<&%T+"!D:69F7W9E8U]P*3L*
M("`)("`@("`@<G1X(&1I<W!A=&-H(#T@<')E=E]R96%L7VEN<VX@*&EN<VXI
M.PHK(`D@("`@("!R='@@<V5T.PH@(`H@(`D@("`@("!F;W(@*&D@/2`P.R!I
M(#P@;&5N.R!I*RLI"B`@"0EI9B`H6$584"`H6%9%0T584"`H<&%T+"!D:69F
M7W9E8U]P+"!I*2P@,"D*("`)"2`@("`A/2!815A0("A85D5#15A0("AP870L
M(&1I9F9?=F5C7W`L(#`I+"`P*2D*("`)"2`@8G)E86L["BL@"B`@"2`@("`@
M(&EF("AI(#T](&QE;@H@(`D)("`F)B!D:7-P871C:"`A/2`P"B`@"0D@("8F
M($=%5%]#3T1%("AD:7-P871C:"D@/3T@2E5-4%])3E-."B`@"0D@("8F($I5
M35!?3$%"14P@*&1I<W!A=&-H*2`A/2`P"B$@"0D@("\J($1O;B=T(&UE<W,@
M=VET:"!A(&-A<V5S:2!I;G-N+B`*(2`)"2`@("`@6%A8(&%C8V]R9&EN9R!T
M;R!T:&4@8V]M;65N="!B969O<F4@8V]M<'5T961?:G5M<%]P*"DL"B$@"0D@
M("`@(&%L;"!C87-E<VD@:6YS;G,@<VAO=6QD(&)E(&$@<&%R86QL96P@;V8@
M=&AE(&IU;7`*(2`)"2`@("`@86YD(&$@55-%(&]F(&$@3$%"14Q?4D5&+B`@
M*B\*(2`)"2`@)B8@(2`H*'-E="`]('-I;F=L95]S970@*&1I<W!A=&-H*2D@
M(3T@3E5,3`HA(`D)"28F("A'151?0T]$12`H4T547U-20R`H<V5T*2D@/3T@
M249?5$A%3E]%3%-%*2D*("`)"2`@)B8@;F5X=%]R96%L7VEN<VX@*$I535!?
M3$%"14P@*&1I<W!A=&-H*2D@/3T@:6YS;BD*("`)"7L*("`)"2`@<F5D:7)E
88W1?=&%B;&5J=6UP("AD:7-P871C:"P*
`
end

>Release-Note:
>Audit-Trail:
>Unformatted: