On Fri, Oct 19, 2001 at 09:59:10AM +0100, Russell King - ARM Linux wrote: > On Fri, Oct 19, 2001 at 01:03:05AM +0200, Klaus Borchers wrote: > > I think I came across a possible bug in gcc when using -O2 optimisation > > on using the following program . > > > > When executed, the function returns "99", i.e. at the time the switch(sw) is > > calculated, the wrong case is taken. > > > > I have tried three different compilers, and all showed the problem : > > > > > gcc version 2.95.2 20000220 (Debian GNU/Linux) (native >onSA1110) > > > gcc version 2.95.3 20010125 (prerelease) (native on >skiffclusters2.handhelds.org) > > > gcc version egcs-2.91.60 19990113/philb (egcs-1.1.1 release) (cross-compiler >hosted on x86) > > I have just tested: > gcc 2.96 built from redhat on ARM: > gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-80)
What kind of compiler is this? A native compiler or a cross compiler? > And what we have is (this includes your compilers): > > version host result > ---------------------------------------------------------------------- > 2.7.2.2 arm ok > egcs-2.91.60 19990113/philb (egcs-1.1.1 release) x86 bad > egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) arm bad > egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) x86 bad > 2.95.1 19990816 (release) arm ok > 2.95.2 20000220 (Debian GNU/Linux) arm bad > 2.95.2 20000516 (release) [Rebel.com] arm ok > 2.95.3 20010125 (prerelease) arm bad > 2.95.3 20010315 (release) x86 bad > 2.96 20000731 (Red Hat Linux 7.1 2.96-80) arm ok > > Hope this provides some clues. I'll throw in my compilers: gcc version 2.95.2 20000220 (Debian GNU/Linux) native x86 ok gcc version 3.0 native x86 bad gcc version 3.0 (*) x86 -> arm ok The (*) compiler is my compiler as available on the ARM Linux FTP site. This compiler is a basic gcc-3.0 compiler with the following Debian patches applied: patches from gcc-3.0-3.0.ds9 snapshot: arm-const-double.dpatch arm-tune.dpatch g++-cxa-atexit.dpatch java-manpages.dpatch libstdc++-limits.dpatch objc-data-references.dpatch objc-testsuite.dpatch subreg-byte.dpatch Interesting to see that the 2.95.2 Debian cross compiler produces bad code, while the native compiler produces correct results. AFAIK both compilers are build from the same codebase. OTOH: In the gcc-3.0 case it's just the other way around: cross compiler is OK, native compiler not. I'm not yet sure why this is, I'll compile a native gcc-3.0 with the debian patches applied tomorrow and will test again. I'll also build a native and cross gcc-3.0.1 compiler. I'll keep you informed. Erik -- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department of Electrical Engineering, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: [EMAIL PROTECTED] WWW: http://www-ict.its.tudelft.nl/~erik/ _______________________________________________ http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm Please visit the above address for information on this list.
