public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52326] New: float result incorrect with -O1 and calling external function.
@ 2012-02-21 13:13 baugesta at cisco dot com
2012-02-21 13:28 ` [Bug rtl-optimization/52326] [4.6 Regression] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: baugesta at cisco dot com @ 2012-02-21 13:13 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
2012-02-21 13:13 [Bug c/52326] New: float result incorrect with -O1 and calling external function baugesta at cisco dot com
@ 2012-02-21 13:28 ` rguenth at gcc dot gnu.org
2012-02-21 13:34 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-21 13:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-*-*
Status|UNCONFIRMED |NEW
Known to work| |4.5.3, 4.7.0
Keywords| |wrong-code
Last reconfirmed| |2012-02-21
Component|c |rtl-optimization
Ever Confirmed|0 |1
Summary|float result incorrect with |[4.6 Regression] float
|-O1 and calling external |result incorrect with -O1
|function. |and calling external
| |function.
Target Milestone|--- |4.6.3
Known to fail| |4.6.0, 4.6.2
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-21 13:20:34 UTC ---
Confirmed. foo.c is unrelated and can be compiled with -O0. Works with 4.5.3,
fails with 4.6.0 already, works with 4.7. The tree level looks good to me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
2012-02-21 13:13 [Bug c/52326] New: float result incorrect with -O1 and calling external function baugesta at cisco dot com
2012-02-21 13:28 ` [Bug rtl-optimization/52326] [4.6 Regression] " rguenth at gcc dot gnu.org
@ 2012-02-21 13:34 ` rguenth at gcc dot gnu.org
2012-02-21 20:28 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-21 13:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-21 13:27:23 UTC ---
Reduced single-file testcase, fails at -O1:
float fabsf(float x);
void abort (void);
static float minf(float a, float b)
{
return (a < b) ? a: b;
}
static float maxf(float a, float b)
{
return (a > b) ? a: b;
}
struct EC {
float fftout;
int extragainOn;
};
static float __attribute__((noinline))
foo (float a)
{
asm("");
return a;
}
static struct EC * __attribute__((noinline))
ec_create(void)
{
static struct EC p;
p.fftout = 1.234567f;
p.extragainOn = 1;
return &p;
}
static float ec_process(struct EC *p, float beflev, float estlev)
{
float fullgCorr;
float extrag;
fullgCorr = maxf(0.0f, beflev - estlev) / beflev;
extrag = 1.0f;
if (p->extragainOn)
extrag = minf(1.0f, fullgCorr);
foo(0.0f);
return extrag * p->fftout;
}
int main(void)
{
unsigned int i = 0;
float beflev[] = {11.6f, 1.0f};
float estlev[] = {11.5f, 1.0f};
float output;
struct EC *p = ec_create();
/* NOTE: If the for-loop is removed, the error disappears */
for (i = 0; i < 1; i++)
output = ec_process(p, beflev[i], estlev[i]);
if (fabsf(output - 0.010643f) < 1e-5f)
return 0;
else
abort ();
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
2012-02-21 13:13 [Bug c/52326] New: float result incorrect with -O1 and calling external function baugesta at cisco dot com
2012-02-21 13:28 ` [Bug rtl-optimization/52326] [4.6 Regression] " rguenth at gcc dot gnu.org
2012-02-21 13:34 ` rguenth at gcc dot gnu.org
@ 2012-02-21 20:28 ` jakub at gcc dot gnu.org
2012-03-01 15:03 ` [Bug target/52326] " jakub at gcc dot gnu.org
2013-04-12 16:17 ` jakub at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-21 20:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-02-21 20:22:59 UTC ---
Works on the trunk since
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174664
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
2012-02-21 13:13 [Bug c/52326] New: float result incorrect with -O1 and calling external function baugesta at cisco dot com
` (2 preceding siblings ...)
2012-02-21 20:28 ` jakub at gcc dot gnu.org
@ 2012-03-01 15:03 ` jakub at gcc dot gnu.org
2013-04-12 16:17 ` jakub at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-01 15:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.6.3 |4.6.4
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-01 14:38:02 UTC ---
GCC 4.6.3 is being released.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
2012-02-21 13:13 [Bug c/52326] New: float result incorrect with -O1 and calling external function baugesta at cisco dot com
` (3 preceding siblings ...)
2012-03-01 15:03 ` [Bug target/52326] " jakub at gcc dot gnu.org
@ 2013-04-12 16:17 ` jakub at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-12 16:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|4.6.4 |4.7.0
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-12 16:17:23 UTC ---
The 4.6 branch has been closed, fixed in GCC 4.7.0.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-12 16:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-21 13:13 [Bug c/52326] New: float result incorrect with -O1 and calling external function baugesta at cisco dot com
2012-02-21 13:28 ` [Bug rtl-optimization/52326] [4.6 Regression] " rguenth at gcc dot gnu.org
2012-02-21 13:34 ` rguenth at gcc dot gnu.org
2012-02-21 20:28 ` jakub at gcc dot gnu.org
2012-03-01 15:03 ` [Bug target/52326] " jakub at gcc dot gnu.org
2013-04-12 16:17 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).