This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/7054: #pragma pack handled incorrectly
- From: jbeulich at novell dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 17 Jun 2002 12:08:00 -0000
- Subject: c/7054: #pragma pack handled incorrectly
- Reply-to: jbeulich at novell dot com
>Number: 7054
>Category: c
>Synopsis: #pragma pack handled incorrectly
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Jun 17 05:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Jan Beulich
>Release: 3.1
>Organization:
>Environment:
Cygwin-hosted cross compilers
>Description:
There are a couple of problems with #pragma pack, the most
severe of which is that the sequence of
#pragma pack(push, 8)
#pragma pack(2)
#pragma pack(pop)
leaves the packing set to 2. See example below.
The other issues are (a) the lack of the ability to specify
a default alignment from the command line (in which case the
plain #pragma pack() would have to restore that alignment
rather than zero) and (b) the failure to accept
#pragma pack(push) (i.e. without a new alignment, which
would be assumed to be set in a subsequent #pragma pack).
>How-To-Repeat:
#pragma pack(push, 8)
#pragma pack(2)
#pragma pack(pop)
struct s {
unsigned u1;
unsigned long long ull;
unsigned u2;
};
unsigned test(const struct s*ps) {
return ps->u2;
}
>Fix:
Have SET_GLOBAL_ALIGNMENT() initialize default_alignment
only if alignment_stack is NULL.
>Release-Note:
>Audit-Trail:
>Unformatted: