public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/10667: Optimizer confused when operating on floats as ints.
@ 2003-05-07 16:36 jkain
0 siblings, 0 replies; 2+ messages in thread
From: jkain @ 2003-05-07 16:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 10667
>Category: optimization
>Synopsis: Optimizer confused when operating on floats as ints.
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed May 07 16:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Joseph Kain
>Release: gcc version 3.2.3
>Organization:
>Environment:
Linux 2.4, i686.
>Description:
The program below was built as:
gcc -v -save-temps -O3 -c -o bug.o bug.c
$ gcc -v
Reading specs from /home/joseph/t/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/home/joseph/t/gcc
Thread model: posix
gcc version 3.2.3
If I examine the assembly output I find that the compiler has completely removed the multiply. Code for the compare is generated but the compare result may be wrong since f.x was never computed.
>How-To-Repeat:
# 1 "bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.c"
struct vector {
float x, y, z, w;
};
int func (float f1, float f2) {
struct vector f;
f.x = f1 * f2;
if ((*(int *) &(f.x)) > 0) {
return 1;
}
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: optimization/10667: Optimizer confused when operating on floats as ints.
@ 2003-05-07 17:01 ebotcazou
0 siblings, 0 replies; 2+ messages in thread
From: ebotcazou @ 2003-05-07 17:01 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jkain, nobody
Synopsis: Optimizer confused when operating on floats as ints.
State-Changed-From-To: open->closed
State-Changed-By: ebotcazou
State-Changed-When: Wed May 7 17:01:24 2003
State-Changed-Why:
Not a bug. Your code breaks the ISO C aliasing rules. GCC
automatically turns on -fstrict-aliasing at -O2 so you need
to fix your code or compile it with -fno-strict-aliasing.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10667
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-07 17:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-07 16:36 optimization/10667: Optimizer confused when operating on floats as ints jkain
2003-05-07 17:01 ebotcazou
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).