From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28919 invoked by alias); 14 Feb 2003 13:06:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 28899 invoked by uid 71); 14 Feb 2003 13:06:00 -0000 Resent-Date: 14 Feb 2003 13:06:00 -0000 Resent-Message-ID: <20030214130600.28898.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, mark@codesourcery.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, matz@suse.de Received: (qmail 22482 invoked by uid 48); 14 Feb 2003 12:59:49 -0000 Message-Id: <20030214125949.22481.qmail@sources.redhat.com> Date: Fri, 14 Feb 2003 13:06:00 -0000 From: matz@suse.de Reply-To: matz@suse.de To: gcc-gnats@gcc.gnu.org Cc: mark@codesourcery.com X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: mark@codesourcery.com Subject: c++/9704: miscompiles openoffice (deals with bitfield members) X-SW-Source: 2003-02/txt/msg00611.txt.bz2 List-Id: >Number: 9704 >Category: c++ >Synopsis: miscompiles openoffice (deals with bitfield members) >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Feb 14 13:06:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: matz@suse.de >Release: 3.3 20030123 CVS and HEAD >Organization: >Environment: i686-linux >Description: The below testcase is miscompiled, and this affects openoffice. This is the case since september last year (i.e. in 3.3 and HEAD). ---------------- snip ----------------- struct BOOL { int nVal:1, bSet:1; BOOL (int i) : nVal(i!=0), bSet(1) {} }; struct Fill { void *d; Fill() : d(0) {} Fill( const Fill& ) {} }; struct SvMetaSlot { Fill aGroupId; #ifdef OUTLINE_CCTOR BOOL a1; BOOL a2; BOOL a3; BOOL a4; BOOL a5; BOOL a6; BOOL a7; #endif BOOL a8; SvMetaSlot() : #ifdef OUTLINE_CCTOR a1(0), a2(0), a3(0), a4(0), a5(0), a6(0), a7(0), #endif a8(1) {} SvMetaSlot* MakeClone() const; }; SvMetaSlot* SvMetaSlot::MakeClone() const { return new SvMetaSlot( *this ); } extern "C" void abort(void); int main() { SvMetaSlot s; SvMetaSlot s2(s); if (s.a8.bSet != s2.a8.bSet) abort (); return 0; } -------------- snap ------------- Compile it with -O1 (or -O2), and see it abort. When -DOUTLINE_CCTOR is given, the implicit cctor of SvMetaSlot is created in an out-of-line copy, so it can be analyzed easier. If it's not given, the cctor in inlined into the MakeClone() method, but the outcome is the same. Note how the BOOL class uses just bitfield members. What happens is, that all the BOOL members of SvMetaSlot are not copied in the synthetic copy ctor. There is no RTL generated for copying those members, for instance the assembler output for the out-of-line copy on i686 is: SvMetaSlot::SvMetaSlot[in-charge](SvMetaSlot const&): pushl %ebp movl %esp, %ebp popl %ebp ret The miscompile happens with cvs -D"2002-09-30 19:00", but not with -D"2002-09-30 18:21", and the only patch during that period is Marks: +2002-09-30 Mark Mitchell + + * class.c (walk_subobject_offsets): Correct the calculation of + offsets for virtual bases. Correct the counting of array + elements. + (layout_nonempty_base_or_field): Simplify. Correct the + calculation of offsets to be propagated through the binfo + hierarchy. + (build_base_field): Avoid creating a FIELD_DECL for empty bases. + .... >How-To-Repeat: Compile the above testcase with g++ (no matter what -O option), on i686-linux (x86-64 breaks too), run it. It will abort. >Fix: >Release-Note: >Audit-Trail: >Unformatted: