This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 2.95.1 alias analysis bug


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]