public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jbeulich@novell.com
To: gcc-gnats@gcc.gnu.org
Subject: c/7054: #pragma pack handled incorrectly
Date: Mon, 17 Jun 2002 05:46:00 -0000	[thread overview]
Message-ID: <20020617120800.12148.qmail@sources.redhat.com> (raw)


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


                 reply	other threads:[~2002-06-17 12:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020617120800.12148.qmail@sources.redhat.com \
    --to=jbeulich@novell.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).