From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7A6FE385841A; Wed, 7 Sep 2022 16:26:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A6FE385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662568015; bh=D/CYBcgaTJeG/kNcEqxrWRf0aj//ZciUfh5mduaYAAc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Rgr5FOEppsEnoqfVBUvqNO6ZsNOdXgM1T5Vm4W3XZ0CZhu+DVNLVHlp6cm8jLv1cn amQt8I2MhvoAQ4wcxanpZO3treq7rg9WZ5/ySR7FLsdHPj3GiYf/1Dpxwlk4GK/VKo /FbhoS8UDHywxWDoLYw67CBZO7AtIrDDAbK1ywa8= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106873] unsigned short skips byte when used for memory mapping depending on position in structure Date: Wed, 07 Sep 2022 16:26:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: resolution bug_status 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106873 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski --- I think you need to use bitfields to get this exact layout or use the attri= bute packed. With -Wpadded I get the following warnings: :19:17: warning: padding struct to align '::b' [-Wpadded] 19 | unsigned short b; // 2 bytes - skips one byte here | ^ :17:1: warning: padding struct size to alignment boundary [-Wpadded] 17 | { | ^ :32:17: warning: padding struct to align '::e' [-Wpadded] 32 | unsigned short e; // 2 bytes - skips one byte here | ^ :27:1: warning: padding struct size to alignment boundary [-Wpadded] 27 | { | ^ :39:17: warning: padding struct to align '::b' [-Wpadded] 39 | unsigned short b; // 2 bytes - skips one byte here | ^ :41:17: warning: padding struct to align '::d' [-Wpadded] 41 | unsigned short d; // 2 bytes - skips one byte here | ^ Which I think is what you are missing is that the ABI is layed out this way= .=