Date: Thu, 10 Aug 1995 17:49:34 -0600 From: Nate Williams <nate@trout.sri.MT.net> To: hackers@FreeBSD.org Subject: Serious GCC optimization bug on x86 Message-ID: <199508102349.RAA02602@trout.sri.MT.net>
next in thread | raw e-mail | index | archive | help
Path: helena.MT.net!news.sprintlink.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!space.mit.edu!davis From: davis@space.mit.edu (John E. Davis) Newsgroups: comp.os.linux.development.system,comp.os.linux.development.apps Subject: Warning to those who use gcc Date: 8 Aug 1995 18:35:43 GMT Organization: Center for Space Research Lines: 47 Message-ID: <408apv$hk6@senator-bedfellow.MIT.EDU> Reply-To: davis@space.mit.edu NNTP-Posting-Host: wiwaxia.mit.edu X-Newsreader: slrn (0.7.6.0) Xref: helena.MT.net comp.os.linux.development.system:8963 comp.os.linux.development.apps:5978 Hi, If you use gcc to compile the kernel or any other program under Linux with gcc, do not use -O2 optimization. If you do, then add the -fno-strength-reduce flags. The reason is that gcc -O2 generates the WRONG code for very simple things. I am sure you do not want your kernel to have bugs caused by a buggy compiler. For all I know, some problems that people report may be a result of this bug. The bug that I am referring to is in gcc 2.6.3 as well as in 2.7.0. It is probably also in 2.5.4 but I do not know for sure. Can anyone verify this? Here is a simple program that illustrates the bug. Compile it with and without -O2 and compare. Then compile it with -O2 -fno-strength-reduce. The bug has been reported to the gcc folks. ------------------------------- #include <stdio.h> static int Order_List[100] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static unsigned int Num_Orders = 10; static void print_it (void) { int i; for (i = 0; i < Num_Orders; i++) { fprintf (stdout, "%d %d\n", i, Order_List[i]); } } int main (void) { unsigned int i; for (i = 0; i < Num_Orders; i++) { Order_List[i] = (int) i - 10; } print_it (); return 0; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508102349.RAA02602>