Usage of __attribute__?
Quoted 8 lines · Alan Modra
I don't see this behaviour. I tried
typedef int
_lt_spinlock_t__attribute__((aligned (16))); int a;
int b;_lt_spinlock_tc;
int d;
Quoted 8 lines
and got
.comm a,4,4 .comm b,4,4 .comm c,4,16 .comm d,4,4ie. as expected. Can you post a testcase and version of gcc you used?
OK, I was just writing a test case on my pc and hadn't bothered to test it on hppa. The compiler on my PC was version 2.95.2. The problem doesn't exist on my native hppa gcc, which is version 2.96. So, although it is possible that the bug might be 386 only, most likely the bug was machine independent and was fixed between 2.95.2 and 2.96. I guess I just don't expect to see many compiler bugs on 386, since it has a lot more exposure.
Here's the test case:
typedef int _lt_spinlock_t __attribute__((aligned(16)));
struct test
{
int i1;
int i2;
int i3;
int i4;
};main()
{
struct test foo;
printf("sizeof struct test %d offsets %d %d %d %d\n",
sizeof(struct test),
(unsigned long)&foo.i1 - (unsigned long)&foo, (unsigned long)&foo.i2 - (unsigned long)&foo, (unsigned long)&foo.i3 - (unsigned long)&foo, (unsigned long)&foo.i4 - (unsigned long)&foo);
}
GCC Version 2.95.2 -- Native i386 linux result:
sizeof struct test 64 offsets 0 16 32 48
GCC Version 2.96 -- Native hppa linux result:
sizeof struct test 16 offsets 0 4 8 12
John
Quoted 3 lines · John Marvin
OK, I was just writing a test case on my pc and hadn't bothered to test it on hppa. The compiler on my PC was version 2.95.2. The problem doesn't exist on my native hppa gcc, which is version 2.96. So, although it is
That's good :-) 2.95.2 has other problems with alignment too, if my faulty memory is correct. It doesn't propagate the maximum alignment of fields within a struct to the struct itself, or something like that.
Signature · 1 line
Linuxcare. Support for the Revolution.