Test gcc.c-torture/execute/align-3.c
Geoff Keating
geoffk@apple.com
Wed Jul 11 23:57:00 GMT 2007
On 11/07/2007, at 4:48 PM, Steve Ellcey wrote:
>
> The test gcc.c-torture/execute/align-3.c is failing on most of my
> platforms, including IA64 HP-UX and Linux. The test consists of:
>
> void func(void) __attribute__((aligned(256)));
>
> void func(void)
> {
> }
>
> int main()
> {
> if (((long)func & 0xFF) != 0)
> abort ();
> if (__alignof__(func) != 256)
> abort ();
> return 0;
> }
>
> The problem I am having is with the first test, checking that the
> address of func is aligned. The problem is that using func in this
> way
> on IA64 gives me the address of the function descriptor, not the
> address
> of the function itself. And while the function address does appear to
> be aligned on a 256 byte boundry, the function descriptor has its
> normal
> 8 byte alignment. My question is, should function descriptors have
> the
> same alignment as functions or is this just an invalid test on systems
> that use function descriptors?
I knew there was a reason that first test wouldn't work on some
platform, it seemed too good to be true.
The compiler understands that a pointer-to-function need not actually
have the same low bits clear as the address of the function itself, so
it's OK for the descriptor to not be aligned as much as the function
to which it points.
Feel free to either (a) #ifdef out the first part of the test on IA64,
or (b) delete the first part of the test altogether.
More information about the Gcc
mailing list