From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11673 invoked by alias); 23 Jun 2014 14:52:03 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 11611 invoked by uid 48); 23 Jun 2014 14:51:59 -0000 From: "dominiq at lps dot ens.fr" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: objc X-Bugzilla-Version: 4.6.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: WAITING X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-06/txt/msg01785.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50909 Dominique d'Humieres changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Last reconfirmed| |2014-06-23 Ever confirmed|0 |1 --- Comment #7 from Dominique d'Humieres --- > 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 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.