This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug objc/50909] Process "#pragma options align=reset" correctly on Mac OS X


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]