From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24420 invoked by alias); 30 Jan 2015 10:33:58 -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 24279 invoked by uid 48); 30 Jan 2015 10:33:53 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/61458] std::aligned_storage is bigger than expected Date: Fri, 30 Jan 2015 10:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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: 2015-01/txt/msg03497.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61458 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paolo at gcc dot gnu.org --- Comment #2 from Jonathan Wakely --- The problem is the default value of the _Align parameter, which comes from alignof(__aligned_storage_msa<_Len>::__type) which is always the maximum alignment: template struct __aligned_storage_msa { union __type { unsigned char __data[_Len]; struct __attribute__((__aligned__)) { } __align; }; }; That effectively ignores _Len and will always have 16-byte alignment, which means sizeof(aligned_storage) is always at least 16 bytes. Should the attribute be using __aligned__(_Len) or does that do the wrong thing in some cases?