From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7D3D93858C27; Mon, 25 Oct 2021 11:01:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D3D93858C27 From: "emmiller at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug objc/50909] Process "#pragma options align=reset" correctly on Mac OS X Date: Mon, 25 Oct 2021 11:01:35 +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: emmiller at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2021 11:01:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D50909 Evan Miller changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |emmiller at gmail dot com --- Comment #16 from Evan Miller --- An unusual but viable workaround for this problem is: #pragma options align=3Dpower #pragma options align=3Dpower #pragma options align=3Dpower #pragma options align=3Dpower #pragma options align=3Dpower #include This technique pre-loads the "options" alignment stack with five default values. When #pragma pack(1) is encountered in the header file, the global alignment is set to 1 byte. T= hen when #pragma options align=3Dreset is encountered, a value is popped off the options stack and the global alignment is set to the value at the top of the stack ("power" which is implemented as the platform default). So the pack and options pragmas inside the header file end up having the desired effect. If the number of "align=3Dpower" pragmas before the header inclusion equals= the number of "align=3Dreset" pragmas inside the header, then after inclusion, = the alignment stack will be whatever it was before all the "align=3Dpower" prag= mas. It probably won't hurt anything to have extra values on the alignment stack= , so you can add a few more to be safe.=