public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: matz@suse.de
To: gcc-gnats@gcc.gnu.org
Cc: mark@codesourcery.com
Subject: c++/9704: miscompiles openoffice (deals with bitfield members)
Date: Fri, 14 Feb 2003 13:06:00 -0000	[thread overview]
Message-ID: <20030214125949.22481.qmail@sources.redhat.com> (raw)


>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  <mark@codesourcery.com>
+
+       * 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:


                 reply	other threads:[~2003-02-14 13:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030214125949.22481.qmail@sources.redhat.com \
    --to=matz@suse.de \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).