This is the mail archive of the gcc@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]
Other format: [Raw text]

RE: ARM constant folding bug?


On 03 August 2007 18:35, Nathan Froyd wrote:

> On Fri, Aug 03, 2007 at 06:24:06PM +0100, Paul Brook wrote:
>> On Friday 03 August 2007, Jonathan S. Shapiro wrote:
>>> Then it seems very curious that the constant folding should fail on this
>>> platform. Any idea what may be going on here?
>> 
>> You're exploiting a hole in the C aliasing rules by accessing a 32-bit int
>> as type char. I tested several compilers (4.2, 4.1 and 3.4 x86, 4.2 m68k
>> and 4.2 arm) and the only one that eliminated the comparison was 3.4-x86.
> 
> FWIW, rewriting it with the "obvious" union approach seems to give the
> desired results on 4.2 arm with and without -mbig-endian.

  Shouldn't it also work by changing the (char *) cast to (unsigned char *),
since IIUIC the standard guarantees you're allowed to access any object as an
array of unsigned char and not get into aliasing difficulties?


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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