Issue Details (XML | Word | Printable)

Key: PCC-208
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

union attributes not being interpreted?

Created: 04/Jan/11 03:14 PM   Updated: 20/Feb/11 11:20 AM
Component/s: pcc backend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
the following code when built with pcc (intending to create a 48-bit foo) creates a value with different size than gcc

union __attribute__((__packed__)) {
char b[6];
short w[3];
long l[1];
} foo;

as evinced by the assembler output

% pcc -S union.c && cat union.s
.comm foo,010,4
.ident "PCC: pcc 0.9.9 [20110104] (netbsd)"

% gcc -S union.c && cat union.s
.file "union.c"
.comm foo,6,1
.ident "GCC: (GNU) 4.1.3 20080704 prerelease (NetBSD nb2 20081120)"

I didn't look into the reasons for this, and using

union {
char b[6];
short w[3];
long l[1];
} __attribute((__packed__)) foo;

does work correctly..

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 20/Feb/11 11:20 AM
Fixed now. The recalculation of struct member offsets were not called if the attribute were prepended.