<< Back to previous view

[PCC-25] packed structures are not correct Created: 29/Jan/09  Updated: 07/May/14

Status: Closed
Project: pcc
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Gregory McGarry Assignee: Anders Magnusson
Resolution: Cannot Reproduce Votes: 0
Environment: virtually all targets


 Description   
The file align.c in pcc-tests illustrates the difference in packed structures between gcc and pcc. The packing behaviour of pcc isn't intuitive.

I think this is the problem with the NetBSD kernel not bootting. I'm confident it is responsible for other issues.



 Comments   
Comment by Anders Magnusson [ 29/Jan/09 10:44 AM ]
It seems to be the _Pragma("packed") code that fails, using __attribute__((packed)) code gives the same result as gcc.
Comment by Gregory McGarry [ 04/Feb/09 04:56 AM ]
pcc-tests/tests/c/codegen/align.c produces different results between gcc and pcc on all the system I have access to. Including using __attribute__((packed)).

Looks like it has something to do with alignment in packed structures.

Comment by Anders Magnusson [ 05/Feb/09 08:28 PM ]
align.c gives the same result for me now with both pcc (both attribute and pragma) and gcc:

openpcc:/home/ragge/foo/pcc-tests/tests/c/codegen >pcc align.c && ./a.out >! pcc-pcaked
openpcc:/home/ragge/foo/pcc-tests/tests/c/codegen >gcc align.c && ./a.out > ! gcc-pcaked
openpcc:/home/ragge/foo/pcc-tests/tests/c/codegen >cmp pcc-pcaked gcc-pcaked
openpcc:/home/ragge/foo/pcc-tests/tests/c/codegen >echo $status
0
Comment by Gregory McGarry [ 06/Feb/09 12:28 AM ]
OSX/i386 still doesn't produce the same structure sizes. Ignore the sizes of long double.

--- gcc.txt 2009-02-06 10:18:35.000000000 +1100
+++ pcc.txt 2009-02-06 10:18:26.000000000 +1100
@@ -6,43 +6,43 @@
 sizeof(long long) = 8
 sizeof(float) = 4
 sizeof(double) = 8
-sizeof(long double) = 16
+sizeof(long double) = 12
 sizeof(bool_st_pad0) = 1, offsetof(filed)=0
 sizeof(packed_bool_st_pad0) = 1, offsetof(filed)=0
 sizeof(bool_st_pad1) = 2, offsetof(filed)=1
 sizeof(packed_bool_st_pad1) = 2, offsetof(filed)=1
 sizeof(bool_st_pad2) = 4, offsetof(filed)=2
-sizeof(packed_bool_st_pad2) = 3, offsetof(filed)=2
+sizeof(packed_bool_st_pad2) = 4, offsetof(filed)=2
 sizeof(bool_st_pad4) = 8, offsetof(filed)=4
-sizeof(packed_bool_st_pad4) = 5, offsetof(filed)=4
+sizeof(packed_bool_st_pad4) = 8, offsetof(filed)=4
 sizeof(bool_st_pad8) = 12, offsetof(filed)=8
-sizeof(packed_bool_st_pad8) = 9, offsetof(filed)=8
+sizeof(packed_bool_st_pad8) = 12, offsetof(filed)=8
 sizeof(char_st_pad0) = 1, offsetof(filed)=0
 sizeof(packed_char_st_pad0) = 1, offsetof(filed)=0
 sizeof(char_st_pad1) = 2, offsetof(filed)=1
 sizeof(packed_char_st_pad1) = 2, offsetof(filed)=1
 sizeof(char_st_pad2) = 4, offsetof(filed)=2
-sizeof(packed_char_st_pad2) = 3, offsetof(filed)=2
+sizeof(packed_char_st_pad2) = 4, offsetof(filed)=2
 sizeof(char_st_pad4) = 8, offsetof(filed)=4
-sizeof(packed_char_st_pad4) = 5, offsetof(filed)=4
+sizeof(packed_char_st_pad4) = 8, offsetof(filed)=4
 sizeof(char_st_pad8) = 12, offsetof(filed)=8
-sizeof(packed_char_st_pad8) = 9, offsetof(filed)=8
+sizeof(packed_char_st_pad8) = 12, offsetof(filed)=8
 sizeof(short_st_pad0) = 2, offsetof(filed)=0
 sizeof(packed_short_st_pad0) = 2, offsetof(filed)=0
 sizeof(short_st_pad1) = 4, offsetof(filed)=2
-sizeof(packed_short_st_pad1) = 3, offsetof(filed)=1
+sizeof(packed_short_st_pad1) = 4, offsetof(filed)=2
 sizeof(short_st_pad2) = 4, offsetof(filed)=2
 sizeof(packed_short_st_pad2) = 4, offsetof(filed)=2
 sizeof(short_st_pad4) = 8, offsetof(filed)=4
-sizeof(packed_short_st_pad4) = 6, offsetof(filed)=4
+sizeof(packed_short_st_pad4) = 8, offsetof(filed)=4
 sizeof(short_st_pad8) = 12, offsetof(filed)=8
-sizeof(packed_short_st_pad8) = 10, offsetof(filed)=8
+sizeof(packed_short_st_pad8) = 12, offsetof(filed)=8
 sizeof(int_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_int_st_pad0) = 4, offsetof(filed)=0
 sizeof(int_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_int_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_int_st_pad1) = 8, offsetof(filed)=4
 sizeof(int_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_int_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_int_st_pad2) = 8, offsetof(filed)=4
 sizeof(int_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_int_st_pad4) = 8, offsetof(filed)=4
 sizeof(int_st_pad8) = 12, offsetof(filed)=8
@@ -50,9 +50,9 @@
 sizeof(long_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_long_st_pad0) = 4, offsetof(filed)=0
 sizeof(long_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_long_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_long_st_pad1) = 8, offsetof(filed)=4
 sizeof(long_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_long_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_long_st_pad2) = 8, offsetof(filed)=4
 sizeof(long_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_long_st_pad4) = 8, offsetof(filed)=4
 sizeof(long_st_pad8) = 12, offsetof(filed)=8
@@ -60,9 +60,9 @@
 sizeof(longlong_st_pad0) = 8, offsetof(filed)=0
 sizeof(packed_longlong_st_pad0) = 8, offsetof(filed)=0
 sizeof(longlong_st_pad1) = 12, offsetof(filed)=4
-sizeof(packed_longlong_st_pad1) = 9, offsetof(filed)=1
+sizeof(packed_longlong_st_pad1) = 12, offsetof(filed)=4
 sizeof(longlong_st_pad2) = 12, offsetof(filed)=4
-sizeof(packed_longlong_st_pad2) = 10, offsetof(filed)=2
+sizeof(packed_longlong_st_pad2) = 12, offsetof(filed)=4
 sizeof(longlong_st_pad4) = 12, offsetof(filed)=4
 sizeof(packed_longlong_st_pad4) = 12, offsetof(filed)=4
 sizeof(longlong_st_pad8) = 16, offsetof(filed)=8
@@ -70,9 +70,9 @@
 sizeof(float_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_float_st_pad0) = 4, offsetof(filed)=0
 sizeof(float_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_float_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_float_st_pad1) = 8, offsetof(filed)=4
 sizeof(float_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_float_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_float_st_pad2) = 8, offsetof(filed)=4
 sizeof(float_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_float_st_pad4) = 8, offsetof(filed)=4
 sizeof(float_st_pad8) = 12, offsetof(filed)=8
@@ -80,29 +80,29 @@
 sizeof(double_st_pad0) = 8, offsetof(filed)=0
 sizeof(packed_double_st_pad0) = 8, offsetof(filed)=0
 sizeof(double_st_pad1) = 12, offsetof(filed)=4
-sizeof(packed_double_st_pad1) = 9, offsetof(filed)=1
+sizeof(packed_double_st_pad1) = 12, offsetof(filed)=4
 sizeof(double_st_pad2) = 12, offsetof(filed)=4
-sizeof(packed_double_st_pad2) = 10, offsetof(filed)=2
+sizeof(packed_double_st_pad2) = 12, offsetof(filed)=4
 sizeof(double_st_pad4) = 12, offsetof(filed)=4
 sizeof(packed_double_st_pad4) = 12, offsetof(filed)=4
 sizeof(double_st_pad8) = 16, offsetof(filed)=8
 sizeof(packed_double_st_pad8) = 16, offsetof(filed)=8
-sizeof(ldouble_st_pad0) = 16, offsetof(filed)=0
-sizeof(packed_ldouble_st_pad0) = 16, offsetof(filed)=0
-sizeof(ldouble_st_pad1) = 32, offsetof(filed)=16
-sizeof(packed_ldouble_st_pad1) = 17, offsetof(filed)=1
-sizeof(ldouble_st_pad2) = 32, offsetof(filed)=16
-sizeof(packed_ldouble_st_pad2) = 18, offsetof(filed)=2
-sizeof(ldouble_st_pad4) = 32, offsetof(filed)=16
-sizeof(packed_ldouble_st_pad4) = 20, offsetof(filed)=4
-sizeof(ldouble_st_pad8) = 32, offsetof(filed)=16
-sizeof(packed_ldouble_st_pad8) = 24, offsetof(filed)=8
+sizeof(ldouble_st_pad0) = 12, offsetof(filed)=0
+sizeof(packed_ldouble_st_pad0) = 12, offsetof(filed)=0
+sizeof(ldouble_st_pad1) = 16, offsetof(filed)=4
+sizeof(packed_ldouble_st_pad1) = 16, offsetof(filed)=4
+sizeof(ldouble_st_pad2) = 16, offsetof(filed)=4
+sizeof(packed_ldouble_st_pad2) = 16, offsetof(filed)=4
+sizeof(ldouble_st_pad4) = 16, offsetof(filed)=4
+sizeof(packed_ldouble_st_pad4) = 16, offsetof(filed)=4
+sizeof(ldouble_st_pad8) = 20, offsetof(filed)=8
+sizeof(packed_ldouble_st_pad8) = 20, offsetof(filed)=8
 sizeof(bool_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_bool_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(bool_ptr_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_bool_ptr_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_bool_ptr_st_pad1) = 8, offsetof(filed)=4
 sizeof(bool_ptr_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_bool_ptr_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_bool_ptr_st_pad2) = 8, offsetof(filed)=4
 sizeof(bool_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_bool_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(bool_ptr_st_pad8) = 12, offsetof(filed)=8
@@ -110,9 +110,9 @@
 sizeof(char_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_char_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(char_ptr_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_char_ptr_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_char_ptr_st_pad1) = 8, offsetof(filed)=4
 sizeof(char_ptr_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_char_ptr_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_char_ptr_st_pad2) = 8, offsetof(filed)=4
 sizeof(char_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_char_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(char_ptr_st_pad8) = 12, offsetof(filed)=8
@@ -120,9 +120,9 @@
 sizeof(short_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_short_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(short_ptr_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_short_ptr_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_short_ptr_st_pad1) = 8, offsetof(filed)=4
 sizeof(short_ptr_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_short_ptr_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_short_ptr_st_pad2) = 8, offsetof(filed)=4
 sizeof(short_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_short_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(short_ptr_st_pad8) = 12, offsetof(filed)=8
@@ -130,9 +130,9 @@
 sizeof(int_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_int_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(int_ptr_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_int_ptr_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_int_ptr_st_pad1) = 8, offsetof(filed)=4
 sizeof(int_ptr_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_int_ptr_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_int_ptr_st_pad2) = 8, offsetof(filed)=4
 sizeof(int_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_int_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(int_ptr_st_pad8) = 12, offsetof(filed)=8
@@ -140,9 +140,9 @@
 sizeof(long_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_long_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(long_ptr_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_long_ptr_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_long_ptr_st_pad1) = 8, offsetof(filed)=4
 sizeof(long_ptr_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_long_ptr_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_long_ptr_st_pad2) = 8, offsetof(filed)=4
 sizeof(long_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_long_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(long_ptr_st_pad8) = 12, offsetof(filed)=8
@@ -150,9 +150,9 @@
 sizeof(longlong_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(packed_longlong_ptr_st_pad0) = 4, offsetof(filed)=0
 sizeof(longlong_ptr_st_pad1) = 8, offsetof(filed)=4
-sizeof(packed_longlong_ptr_st_pad1) = 5, offsetof(filed)=1
+sizeof(packed_longlong_ptr_st_pad1) = 8, offsetof(filed)=4
 sizeof(longlong_ptr_st_pad2) = 8, offsetof(filed)=4
-sizeof(packed_longlong_ptr_st_pad2) = 6, offsetof(filed)=2
+sizeof(packed_longlong_ptr_st_pad2) = 8, offsetof(filed)=4
 sizeof(longlong_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(packed_longlong_ptr_st_pad4) = 8, offsetof(filed)=4
 sizeof(longlong_ptr_st_pad8) = 12, offsetof(filed)=8

Comment by Gregory McGarry [ 06/Feb/09 05:09 AM ]
Oops. OSX/i386 is now good. Working on Ubuntu/i386 now.
Comment by Anders Magnusson [ 12/Sep/09 09:19 AM ]
Status of this?
Comment by Gregory McGarry [ 12/Sep/09 09:52 AM ]
On OSX/pcc:

--- gcc.txt 2009-09-12 17:34:01.000000000 +1000
+++ pcc3.txt 2009-09-12 17:43:43.000000000 +1000
@@ -6,7 +6,7 @@
 sizeof(long long) = 8
 sizeof(float) = 4
 sizeof(double) = 8
-sizeof(long double) = 16
+sizeof(long double) = 12
 sizeof(bool_st_pad0) = 4
 sizeof(packed_bool_st_pad0) = 4
 sizeof(bool_st_pad1) = 8
@@ -15,19 +15,19 @@
 sizeof(packed_bool_st_pad2) = 6
 sizeof(bool_st_pad4) = 8
 sizeof(packed_bool_st_pad4) = 8
-sizeof(bool_st_pad8) = 16
+sizeof(bool_st_pad8) = 12
 sizeof(packed_bool_st_pad8) = 12
-sizeof(char_st_pad0) = 1
+sizeof(char_st_pad0) = 4
 sizeof(packed_char_st_pad0) = 1
-sizeof(char_st_pad1) = 2
+sizeof(char_st_pad1) = 4
 sizeof(packed_char_st_pad1) = 2
 sizeof(char_st_pad2) = 4
 sizeof(packed_char_st_pad2) = 3
 sizeof(char_st_pad4) = 8
 sizeof(packed_char_st_pad4) = 5
-sizeof(char_st_pad8) = 16
+sizeof(char_st_pad8) = 12
 sizeof(packed_char_st_pad8) = 9
-sizeof(short_st_pad0) = 2
+sizeof(short_st_pad0) = 4
 sizeof(packed_short_st_pad0) = 2
 sizeof(short_st_pad1) = 4
 sizeof(packed_short_st_pad1) = 3
@@ -35,7 +35,7 @@
 sizeof(packed_short_st_pad2) = 4
 sizeof(short_st_pad4) = 8
 sizeof(packed_short_st_pad4) = 6
-sizeof(short_st_pad8) = 16
+sizeof(short_st_pad8) = 12
 sizeof(packed_short_st_pad8) = 10
 sizeof(int_st_pad0) = 4
 sizeof(packed_int_st_pad0) = 4
@@ -45,7 +45,7 @@
 sizeof(packed_int_st_pad2) = 6
 sizeof(int_st_pad4) = 8
 sizeof(packed_int_st_pad4) = 8
-sizeof(int_st_pad8) = 16
+sizeof(int_st_pad8) = 12
 sizeof(packed_int_st_pad8) = 12
 sizeof(long_st_pad0) = 4
 sizeof(packed_long_st_pad0) = 4
@@ -55,7 +55,7 @@
 sizeof(packed_long_st_pad2) = 6
 sizeof(long_st_pad4) = 8
 sizeof(packed_long_st_pad4) = 8
-sizeof(long_st_pad8) = 16
+sizeof(long_st_pad8) = 12
 sizeof(packed_long_st_pad8) = 12
 sizeof(longlong_st_pad0) = 8
 sizeof(packed_longlong_st_pad0) = 8
@@ -75,7 +75,7 @@
 sizeof(packed_float_st_pad2) = 6
 sizeof(float_st_pad4) = 8
 sizeof(packed_float_st_pad4) = 8
-sizeof(float_st_pad8) = 16
+sizeof(float_st_pad8) = 12
 sizeof(packed_float_st_pad8) = 12
 sizeof(double_st_pad0) = 8
 sizeof(packed_double_st_pad0) = 8
@@ -87,16 +87,16 @@
 sizeof(packed_double_st_pad4) = 12
 sizeof(double_st_pad8) = 16
 sizeof(packed_double_st_pad8) = 16
-sizeof(ldouble_st_pad0) = 16
-sizeof(packed_ldouble_st_pad0) = 16
-sizeof(ldouble_st_pad1) = 32
-sizeof(packed_ldouble_st_pad1) = 17
-sizeof(ldouble_st_pad2) = 32
-sizeof(packed_ldouble_st_pad2) = 18
-sizeof(ldouble_st_pad4) = 32
-sizeof(packed_ldouble_st_pad4) = 20
-sizeof(ldouble_st_pad8) = 32
-sizeof(packed_ldouble_st_pad8) = 24
+sizeof(ldouble_st_pad0) = 12
+sizeof(packed_ldouble_st_pad0) = 12
+sizeof(ldouble_st_pad1) = 16
+sizeof(packed_ldouble_st_pad1) = 13
+sizeof(ldouble_st_pad2) = 16
+sizeof(packed_ldouble_st_pad2) = 14
+sizeof(ldouble_st_pad4) = 16
+sizeof(packed_ldouble_st_pad4) = 16
+sizeof(ldouble_st_pad8) = 20
+sizeof(packed_ldouble_st_pad8) = 20
 sizeof(bool_ptr_st_pad0) = 4
 sizeof(packed_bool_ptr_st_pad0) = 4
 sizeof(bool_ptr_st_pad1) = 8
@@ -105,7 +105,7 @@
 sizeof(packed_bool_ptr_st_pad2) = 6
 sizeof(bool_ptr_st_pad4) = 8
 sizeof(packed_bool_ptr_st_pad4) = 8
-sizeof(bool_ptr_st_pad8) = 16
+sizeof(bool_ptr_st_pad8) = 12
 sizeof(packed_bool_ptr_st_pad8) = 12
 sizeof(char_ptr_st_pad0) = 4
 sizeof(packed_char_ptr_st_pad0) = 4
@@ -115,7 +115,7 @@
 sizeof(packed_char_ptr_st_pad2) = 6
 sizeof(char_ptr_st_pad4) = 8
 sizeof(packed_char_ptr_st_pad4) = 8
-sizeof(char_ptr_st_pad8) = 16
+sizeof(char_ptr_st_pad8) = 12
 sizeof(packed_char_ptr_st_pad8) = 12
 sizeof(short_ptr_st_pad0) = 4
 sizeof(packed_short_ptr_st_pad0) = 4
@@ -125,7 +125,7 @@
 sizeof(packed_short_ptr_st_pad2) = 6
 sizeof(short_ptr_st_pad4) = 8
 sizeof(packed_short_ptr_st_pad4) = 8
-sizeof(short_ptr_st_pad8) = 16
+sizeof(short_ptr_st_pad8) = 12
 sizeof(packed_short_ptr_st_pad8) = 12
 sizeof(int_ptr_st_pad0) = 4
 sizeof(packed_int_ptr_st_pad0) = 4
@@ -135,7 +135,7 @@
 sizeof(packed_int_ptr_st_pad2) = 6
 sizeof(int_ptr_st_pad4) = 8
 sizeof(packed_int_ptr_st_pad4) = 8
-sizeof(int_ptr_st_pad8) = 16
+sizeof(int_ptr_st_pad8) = 12
 sizeof(packed_int_ptr_st_pad8) = 12
 sizeof(long_ptr_st_pad0) = 4
 sizeof(packed_long_ptr_st_pad0) = 4
@@ -145,7 +145,7 @@
 sizeof(packed_long_ptr_st_pad2) = 6
 sizeof(long_ptr_st_pad4) = 8
 sizeof(packed_long_ptr_st_pad4) = 8
-sizeof(long_ptr_st_pad8) = 16
+sizeof(long_ptr_st_pad8) = 12
 sizeof(packed_long_ptr_st_pad8) = 12
 sizeof(longlong_ptr_st_pad0) = 4
 sizeof(packed_longlong_ptr_st_pad0) = 4
@@ -155,7 +155,7 @@
 sizeof(packed_longlong_ptr_st_pad2) = 6
 sizeof(longlong_ptr_st_pad4) = 8
 sizeof(packed_longlong_ptr_st_pad4) = 8
-sizeof(longlong_ptr_st_pad8) = 16
+sizeof(longlong_ptr_st_pad8) = 12
 sizeof(packed_longlong_ptr_st_pad8) = 12
 sizeof(float_ptr_st_pad0) = 4
 sizeof(packed_float_ptr_st_pad0) = 4
@@ -165,7 +165,7 @@
 sizeof(packed_float_ptr_st_pad2) = 6
 sizeof(float_ptr_st_pad4) = 8
 sizeof(packed_float_ptr_st_pad4) = 8
-sizeof(float_ptr_st_pad8) = 16
+sizeof(float_ptr_st_pad8) = 12
 sizeof(packed_float_ptr_st_pad8) = 12
 sizeof(double_ptr_st_pad0) = 4
 sizeof(packed_double_ptr_st_pad0) = 4
@@ -175,7 +175,7 @@
 sizeof(packed_double_ptr_st_pad2) = 6
 sizeof(double_ptr_st_pad4) = 8
 sizeof(packed_double_ptr_st_pad4) = 8
-sizeof(double_ptr_st_pad8) = 16
+sizeof(double_ptr_st_pad8) = 12
 sizeof(packed_double_ptr_st_pad8) = 12
 sizeof(ldouble_ptr_st_pad0) = 4
 sizeof(packed_ldouble_ptr_st_pad0) = 4
@@ -185,5 +185,5 @@
 sizeof(packed_ldouble_ptr_st_pad2) = 6
 sizeof(ldouble_ptr_st_pad4) = 8
 sizeof(packed_ldouble_ptr_st_pad4) = 8
-sizeof(ldouble_ptr_st_pad8) = 16
+sizeof(ldouble_ptr_st_pad8) = 12
 sizeof(packed_ldouble_ptr_st_pad8) = 12
Comment by Anders Magnusson [ 12/Sep/09 12:38 PM ]
Can you try to change
#define SZLDOUBLE 96
in macdefs.h to 128? It seems like OSX has another size than the rest of x86 for long double.
Comment by Gregory McGarry [ 14/Sep/09 11:13 AM ]
I made this change to macdefs.h. It looks like long double types cannot be packed. Maybe it's not such a big issue.

ndex: macdefs.h
===================================================================
RCS file: /cvsroot/pcc/arch/i386/macdefs.h,v
retrieving revision 1.69
diff -u -r1.69 macdefs.h
--- macdefs.h 27 Apr 2009 22:50:00 -0000 1.69
+++ macdefs.h 14 Sep 2009 09:07:35 -0000
@@ -46,7 +46,11 @@
 #define SZINT 32
 #define SZFLOAT 32
 #define SZDOUBLE 64
+#ifdef MACHOABI
+#define SZLDOUBLE 128
+#else
 #define SZLDOUBLE 96
+#endif
 #define SZLONG 32
 #define SZSHORT 16
 #define SZLONGLONG 64
@@ -60,7 +64,11 @@
 #define ALINT 32
 #define ALFLOAT 32
 #define ALDOUBLE 32
+#ifdef MACHOABI
+#define ALLDOUBLE 128
+#else
 #define ALLDOUBLE 32
+#endif
 #define ALLONG 32
 #define ALLONGLONG 32
 #define ALSHORT 16

However, the assembler doesn't like an alignment of 16 bytes. But I suspect the assembler expects the alignment to be log2 bytes. Here is the result of gcc compiling align.c

.comm _ldouble_st_pad0,16,4
.comm _packed_ldouble_st_pad0,16,4
.comm _ldouble_st_pad1,32,5
.comm _packed_ldouble_st_pad1,17,0
.comm _ldouble_st_pad2,32,5
.comm _packed_ldouble_st_pad2,18,0
.comm _ldouble_st_pad4,32,5
.comm _packed_ldouble_st_pad4,20,0
.comm _ldouble_st_pad8,32,5
.comm _packed_ldouble_st_pad8,24,0




--- gcc.txt 2009-09-14 18:43:36.000000000 +1000
+++ pcc.txt 2009-09-14 18:44:22.000000000 +1000
@@ -89,13 +89,13 @@
 sizeof(packed_double_st_pad8) = 16, offsetof(field)=8
 sizeof(ldouble_st_pad0) = 16, offsetof(field)=0
 sizeof(packed_ldouble_st_pad0) = 16, offsetof(field)=0
-sizeof(ldouble_st_pad1) = 32, offsetof(field)=16
+sizeof(ldouble_st_pad1) = 20, offsetof(field)=4
 sizeof(packed_ldouble_st_pad1) = 17, offsetof(field)=1
-sizeof(ldouble_st_pad2) = 32, offsetof(field)=16
+sizeof(ldouble_st_pad2) = 20, offsetof(field)=4
 sizeof(packed_ldouble_st_pad2) = 18, offsetof(field)=2
-sizeof(ldouble_st_pad4) = 32, offsetof(field)=16
+sizeof(ldouble_st_pad4) = 20, offsetof(field)=4
 sizeof(packed_ldouble_st_pad4) = 20, offsetof(field)=4
-sizeof(ldouble_st_pad8) = 32, offsetof(field)=16
+sizeof(ldouble_st_pad8) = 24, offsetof(field)=8
 sizeof(packed_ldouble_st_pad8) = 24, offsetof(field)=8
 sizeof(bool_ptr_st_pad0) = 4, offsetof(field)=0
 sizeof(packed_bool_ptr_st_pad0) = 4, offsetof(field)=0


Comment by Gregory McGarry [ 14/Sep/09 11:29 AM ]
And here's my latest patch for OSX:

cvs diff: Diffing .
Index: local.c
===================================================================
RCS file: /cvsroot/pcc/arch/i386/local.c,v
retrieving revision 1.110
diff -u -r1.110 local.c
--- local.c 7 Sep 2009 08:06:34 -0000 1.110
+++ local.c 14 Sep 2009 09:28:42 -0000
@@ -31,6 +31,15 @@
 
 /* this file contains code which is dependent on the target machine */
 
+static int
+log2(int i)
+{
+ int sh = 1;
+ while (i >>= 1)
+ sh++;
+ return sh;
+}
+
 /*
  * Check if a constant is too large for a type.
  */
@@ -1254,9 +1263,12 @@
  sp->soname ? sp->soname : exname(sp->sname), off);
  else
  printf(LABFMT ",0%o", sp->soffset, off);
-#if !defined(PECOFFABI)
+#if defined(ELFABI)
  if (sp->sclass != STATIC)
  printf(",%d", al);
+#elif defined(MACHOABI)
+ if (sp->sclass != STATIC)
+ printf(",%d", log2(al));
 #endif
  printf("\n");
 }
Index: macdefs.h
===================================================================
RCS file: /cvsroot/pcc/arch/i386/macdefs.h,v
retrieving revision 1.69
diff -u -r1.69 macdefs.h
--- macdefs.h 27 Apr 2009 22:50:00 -0000 1.69
+++ macdefs.h 14 Sep 2009 09:28:42 -0000
@@ -46,7 +46,11 @@
 #define SZINT 32
 #define SZFLOAT 32
 #define SZDOUBLE 64
+#ifdef MACHOABI
+#define SZLDOUBLE 128
+#else
 #define SZLDOUBLE 96
+#endif
 #define SZLONG 32
 #define SZSHORT 16
 #define SZLONGLONG 64
@@ -60,7 +64,11 @@
 #define ALINT 32
 #define ALFLOAT 32
 #define ALDOUBLE 32
+#ifdef MACHOABI
+#define ALLDOUBLE 128
+#else
 #define ALLDOUBLE 32
+#endif
 #define ALLONG 32
 #define ALLONGLONG 32
 #define ALSHORT 16
Comment by Anders Magnusson [ 14/Sep/09 01:37 PM ]
Isn't your log2() the same as ispow2() in optim.c?
Otherwise go ahead.

-- Ragge
Comment by Anders Magnusson [ 07/May/14 02:54 PM ]
Hopefully this works now, otherwise open a new ticket.
Generated at Sat Nov 22 11:24:14 CET 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.