public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/7054: #pragma pack handled incorrectly
@ 2002-06-17  5:46 jbeulich
  0 siblings, 0 replies; only message in thread
From: jbeulich @ 2002-06-17  5:46 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-06-17 12:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-17  5:46 c/7054: #pragma pack handled incorrectly jbeulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).