From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5422 invoked by alias); 21 Feb 2012 12:53:10 -0000 Received: (qmail 5414 invoked by uid 22791); 21 Feb 2012 12:53:09 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CX,TW_GC,TW_GX,TW_IB X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Feb 2012 12:52:56 +0000 From: "baugesta at cisco dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/52326] New: float result incorrect with -O1 and calling external function. Date: Tue, 21 Feb 2012 13:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: baugesta at cisco dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg02070.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326 Bug #: 52326 Summary: float result incorrect with -O1 and calling external function. Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: baugesta@cisco.com Created attachment 26713 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26713 Two source files, one header file and a Makefile The sample program attached fails when built with -O1, but not with any other optimization levels (0,2,3). Unfortunately it only fails when we call an external function, therefore we had to attach a tgz file instead of a preprocessed file. The tar file contains four files: main.c, foo.c, foo.h and a Makefile. The Makefile, which builds two targets (fail and success) can be used to re-create the problem as well as to build a non-failing version. Also, the error only occurs when certain other conditions are met. We've written a C comment for every condition we found in the source file named main.c. Please search for the text "NOTE". GCC Version: ------------ Our GCC version is 4.6.2. It fails on multiple versions/builds of 4.6.2, both the one provided with Gentoo and the one provided by Centos 6. The info below is from my Gentoo host: COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.2/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.2/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.6.2/work/gcc-4.6.2/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.2/python --enable-checking=release --disable-libgcj --disable-libquadmath --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.2 p1.4, pie-0.5.0' Thread model: posix gcc version 4.6.2 (Gentoo 4.6.2 p1.4, pie-0.5.0) The complete command line that triggers the bug: ------------------------------------------------ gcc -o fail -O1 -Wall -Wextra -Wconversion -Werror -Wshadow -Wmissing-declarations -std=c89 main.c foo.c && ./fail (Note that it also fails with less arguments, -O1 is all it takes) Compiler output: --------------- None Preprocessed file: ------------------ Due to the nature of the bug, calling an external function, we could not provide a preprocessed file.