public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug objc/50909] Process "#pragma options align=reset" correctly on Mac OS X
Date: Mon, 23 Jun 2014 14:52:00 -0000	[thread overview]
Message-ID: <bug-50909-4-08AtxirSez@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50909-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50909

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-06-23
     Ever confirmed|0                           |1

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> 3 years later and it still doesn't work... gcc version 4.8.3, installed
> using homebrew on OSX 10.9.3.

Well, you did not fix it, did you?

Reducing the test in comment 0 to

  #include <IOKit/usb/USB.h>

gives

In file included from pr50909_red.c:1:0:
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:584:9: error: too
many #pragma options align=reset
 #pragma options align=reset
         ^
In file included from pr50909_red.c:1:0:
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:754:9: error: too
many #pragma options align=reset
 #pragma options align=reset
         ^
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:806:9: error: too
many #pragma options align=reset
 #pragma options align=reset
         ^
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:824:9: error: too
many #pragma options align=reset
 #pragma options align=reset
         ^
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:844:9: error: too
many #pragma options align=reset
 #pragma options align=reset
         ^

Now looking at the gcc manual I found at
https://gcc.gnu.org/onlinedocs/gcc/Darwin-Pragmas.html#Darwin-Pragmas

options align=alignment
This pragma sets the alignment of fields in structures. The values of alignment
may be mac68k, to emulate m68k alignment, or power, to emulate PowerPC
alignment. Uses of this pragma nest properly; to restore the previous setting,
use reset for the alignment. 

in line with the code in gcc/config/darwin-c.c. I also found at
https://gcc.gnu.org/onlinedocs/gcc/Structure-Packing-Pragmas.html

6.57.8 Structure-Packing Pragmas

For compatibility with Microsoft Windows compilers, GCC supports a set of
#pragma directives that change the maximum alignment of members of structures
(other than zero-width bit-fields), unions, and classes subsequently defined.
The n value below always is required to be a small power of two and specifies
the new alignment in bytes.

#pragma pack(n) simply sets the new alignment.
#pragma pack() sets the alignment to the one that was in effect when
compilation started (see also command-line option -fpack-struct[=n] see Code
Gen Options).
#pragma pack(push[,n]) pushes the current alignment setting on an internal
stack and then optionally sets the new alignment.
#pragma pack(pop) restores the alignment setting to the one saved at the top of
the internal stack (and removes that stack entry). Note that #pragma pack([n])
does not influence this internal stack; thus it is possible to have #pragma
pack(push) followed by multiple #pragma pack(n) instances and finalized by a
single #pragma pack(pop).
Some targets, e.g. i386 and PowerPC, support the ms_struct #pragma which lays
out a structure as the documented __attribute__ ((ms_struct)).

#pragma ms_struct on turns on the layout for structures declared.
#pragma ms_struct off turns off the layout for structures declared.
#pragma ms_struct reset goes back to the default layout.

So AFAIU gcc behaves as documented, while the behavior has been changed in
clang (for which the tests compile).

IMO this PR should be closed as INVALID or WONTFIX, unless someone want to
implement the clang behavior.


  parent reply	other threads:[~2014-06-23 14:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-29  5:03 [Bug objc/50909] New: " carsomyr at gmail dot com
2012-05-23 21:35 ` [Bug objc/50909] " carl at lytro dot com
2012-08-08  8:26 ` roman at qubyx dot com
2013-09-13 18:53 ` dc7000 at att dot com
2013-09-13 19:05 ` dominiq at lps dot ens.fr
2013-09-13 20:32 ` dc7000 at att dot com
2014-06-23 14:52 ` dominiq at lps dot ens.fr [this message]
2014-06-23 15:48 ` alex.wolf at gmail dot com
2014-06-23 16:30 ` manu at gcc dot gnu.org
2021-10-25 11:01 ` emmiller at gmail dot com
2024-06-16 18:44 ` vital.had at gmail dot com

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=bug-50909-4-08AtxirSez@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).