------- Comment #2 from mikpe at it dot uu dot se  2008-03-16 16:49 -------
(In reply to comment #1)
> This happens with 4.1, 4.2 and trunk on old ABI.  Apparently it doesn't
> happen with EABI.
> 

I see the problem too, on Linux/ARM/OABI with gcc-4.1.2.

However, the problem is in the test case itself. Specifically the attempt to
align _b:

> if (((unsigned long)_b)&sizeof(_b)) _b++;

_b is void*, so this is "if (_b & 4) _b += 1;" at the machine level, which is
totally bogus. Om my machine alloca() returned 0xbea1d97c (a multiple of 4 but
not of 8), which this code changed to 0xbea1d97d. The following uses of _b as a
pointer caused numerous alignment exceptions (logged by the kernel).

On the other machines I tested this on (sparc, powerpc, x86), alloca() returned
an address that was a multiple of 8, so the bogus alignment code didn't
trigger.

If you want to align _b to a multiple of 2*sizeof(void*), do something like:
_b = (void*)(((unsigned long)_b + 2*sizeof(void*)-1) & ~(2*sizeof(void*)-1));

Not a gcc bug, IMO.


-- 

mikpe at it dot uu dot se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu dot se


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34652

Reply via email to