From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24193 invoked by alias); 27 Jan 2015 12:27:37 -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 23993 invoked by uid 55); 27 Jan 2015 12:27:19 -0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64798] [5 regression] g++.old-deja/g++.eh/badalloc1.C FAILs Date: Tue, 27 Jan 2015 12:27: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: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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/msg03070.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64798 --- Comment #8 from rguenther at suse dot de --- On Tue, 27 Jan 2015, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64798 > > Jakub Jelinek changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |jakub at gcc dot gnu.org > > --- Comment #6 from Jakub Jelinek --- > __BIGGEST_ALIGNMENT__ is unnecessarily large, e.g. on i?86-linux, it is 16, > while you only need to guarantee 8-byte alignment. > Isn't the bug just in the badalloc1.C testcase, if it provides its own malloc, > it should IMHO guarantee the system malloc alignments (generally, something > like alignment of > union U > { > long long ll; > double d; > long double ld; > void *p; > }; > . no, badalloc1.C provides __BIGGEST_ALIGNMENT__ aligned memory. The bug is in the EH allocator which allocates the extra size_t entry aligned but the EH object itself only size_t aligned. It's documented that __attribute__((aligned)) aligns to the biggest type so using __BIGGEST_ALIGNMENT__ looks correct here - this is also what malloc () guarantees for alignment, no? Do we have any other means of getting the same alignment as malloc () provides? Btw, it still wastes a lot less space than the previous allocator. Bug in the patch anyway and the following hunk is also needed: @@ -185,7 +186,7 @@ namespace { __gnu_cxx::__scoped_lock sentry(emergency_mutex); allocated_entry *e = reinterpret_cast - (reinterpret_cast (data) - sizeof (std::size_t)); + (reinterpret_cast (data) - offsetof (allocated_entry, data)); std::size_t sz = e->size; if (!first_free_entry) {