From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16236 invoked by alias); 26 Aug 2002 00:36:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 16217 invoked by uid 71); 26 Aug 2002 00:36:00 -0000 Resent-Date: 26 Aug 2002 00:36:00 -0000 Resent-Message-ID: <20020826003600.16216.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Petr.Savicky@cuni.cz Received: (qmail 15732 invoked from network); 26 Aug 2002 00:30:04 -0000 Received: from unknown (HELO dec59.ruk.cuni.cz) (195.113.2.17) by sources.redhat.com with SMTP; 26 Aug 2002 00:30:04 -0000 Received: (qmail 24537 invoked by uid 286); 26 Aug 2002 00:30:02 -0000 Message-Id: <20020826003002.GA23874@dec59.ruk.cuni.cz> Date: Sun, 25 Aug 2002 18:16:00 -0000 From: Petr.Savicky@cuni.cz To: gcc-gnats@gcc.gnu.org Subject: optimization/7719: gcc with -O2 generates wrong code X-SW-Source: 2002-08/txt/msg00541.txt.bz2 List-Id: >Number: 7719 >Category: optimization >Synopsis: gcc with -O2 generates wrong code >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Sun Aug 25 17:36:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Petr Savicky >Release: 3.0.4 (SuSE), also 2.95.3 (SuSE) and 2.91.66 (RedHat) >Organization: >Environment: System: Linux linux 2.4.18-4GB #1 Fri Apr 5 15:14:39 UTC 2002 i686 unknown Architecture: i686 host: i486-suse-linux-gnu build: i486-suse-linux-gnu target: i486-suse-linux-gnu configured with: ../configure --enable-threads=posix --enable-long-long --prefix=/opt/experimental --with-local-prefix=/usr/local --enable-languages=c,c++,f77,objc,java --disable-nls --enable-shared i486-suse-linux The exact set of compile options used is: gcc -I$RBASE/include -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c grow.c -o grow.o I tested the problem on three different computers (all PCs with linux). The above info is from one of them. >Description: If compiled with -O2, then at some step of the computation, line 3284 of grow.i (line 400 of grow.c), i.e. if (val >= devtarget || val >= *bval) return; does not perform the return command, although all the variables val, *bval, devtarget are equal. The commands at lines 3285-3290 in grow.i print GROW: 5.924155689933546576 val GROW: 5.924155689933546576 devtarget GROW: 5.924155689933546576 *bval GROW: 0.000000e+00 *bval-val This behaviour is fully deterministic. If compiled without -O2, these lines do not occur in the output. >How-To-Repeat: The preprocessed source code is http://www.cs.cas.cz/~savicky/R_tree/grow.i If you need to run the program in the situation, when the error appears, it is necessary to install R-1.5.1 (www.r-project.org) with the default settings, i.e. with -O2 in gcc and g++ options. Then, perform the following steps: 1. put http://www.cs.cas.cz/~savicky/R_tree/tree_o2_error-3.tar.gz and http://www.cs.cas.cz/~savicky/R_tree/corrupt_tree_o2-2.tar.gz into a work directory and cd to this directory. 2. tar -zxf tree_o2_error-3.tar.gz tar -zxf corrupt_tree_o2-2.tar.gz 3. R CMD INSTALL tree/ 4. cd corrupt_tree 5. R (this should give you the R prompt) 6. source("script.R") (in the R prompt) This should produce the lines with "GROW" copied above. The problem is indeed in a wrong compilation of grow.c. If this file alone is compiled without -O2, linked together with treefix.o into tree.so and copied to $RBASE/library/tree/libs/, the problem disappears. (The script tree/src/recompile.sh, which I used for this recompilation on my computer is included in the tar package). >Fix: Don't use optimization. >Release-Note: >Audit-Trail: >Unformatted: