This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: 2.95.1 alias analysis bug
- To: Peter dot Lawrence at Eng dot Sun dot COM
- Subject: Re: 2.95.1 alias analysis bug
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Thu, 16 Mar 2000 10:34:36 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <200003160134.RAA12290@cloudbase.Eng.Sun.COM>
> The "strict aliasing" new in gcc-2.9 is in conflict with one of gcc's long
> standing extensions, namely allowing a cast as an l-value. The example I
> first ran into was in Cygnus' own printf library function, but is easily
> shown with a test program:
Thanks for your bug report. I think you are confusing some things
here. The program you show does not make use of the lvalue cast
extension, but is syntactically well-formed standard C. In standard C,
it has, of course, an undefined behaviour, as an object of some type
(float) is accessed through a pointer of a different type (int*). So
from the view-point of standard C, your program is clearly wrong, and
the compiler is entirely entitled to do what it does. It also has
nothing to do with GNU extensions; you are not using any.
To use that extension, you'd have to write
float
fred (float p)
{
(int)p = 0x01230000;
return 5.0f * p;
}
AFAICT, the compiler generates correct code for that, as it computes
the result at compile time.
Anyway, for the various problems with -fstrict-aliasing, it was
turned-off by default in gcc 2.95.2. The primary problem is not that
we think it is broken; it is the amount of user confusion that it
created.
Regards,
Martin