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: Test gcc.c-torture/execute/align-3.c



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.


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