[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-31 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

--- Comment #11 from Nathan Sidwell  ---
Applied to gcc-5 branch r234653.

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-31 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

--- Comment #10 from Nathan Sidwell  ---
Author: nathan
Date: Thu Mar 31 20:51:20 2016
New Revision: 234653

URL: https://gcc.gnu.org/viewcvs?rev=234653=gcc=rev
Log:
PR c++/70393
* varasm.c (output_constructor_regular_field): Flush bitfield
earlier.  Assert we don't want to move backwards.

cp/
PR c++/70393
* constexpr.c (cxx_eval_store_expression): Keep CONSTRUCTOR
elements in field order.

testsuite/
PR c++/70393
* g++.dg/cpp0x/constexpr-virtual6.C: New.

Added:
branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-virtual6.C
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/cp/ChangeLog
branches/gcc-5-branch/gcc/cp/constexpr.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog
branches/gcc-5-branch/gcc/varasm.c

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

--- Comment #9 from Jonathan Wakely  ---
Should it be fixed on gcc-5-branch too?

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-31 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

Nathan Sidwell  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Nathan Sidwell  ---
Fixed r234636.

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-31 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

--- Comment #7 from Nathan Sidwell  ---
Author: nathan
Date: Thu Mar 31 15:30:33 2016
New Revision: 234636

URL: https://gcc.gnu.org/viewcvs?rev=234636=gcc=rev
Log:
PR c++/70393
* varasm.c (output_constructor_regular_field): Flush bitfield
earlier.  Assert we don't want to move backwards.

cp/
* constexpr.c (cxx_eval_store_expression): Keep CONSTRUCTOR
elements in field order.

testsuite/
* g++.dg/cpp0x/constexpr-virtual6.C: New.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-virtual6.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/constexpr.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/varasm.c

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-29 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

Nathan Sidwell  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-24 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

--- Comment #6 from Nathan Sidwell  ---
Indeed, manually editing the assembly to such an initializer results in  a
working program.

The CONSTRUCTOR created for ab's  DECL_INITIAL has the correct things in it,
but in declaration  order.  I.e. it looks like:
IDX=field-for-A-base VAL=CONSTRUCTOR (...)
IDX=field-for-B-base VAL=CONSTRUCTOR (...)

I think CONSTRUCTOR_ELTs are expected to be in ascending placement order?

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-24 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

Nathan Sidwell  changed:

   What|Removed |Added

 CC||nathan at gcc dot gnu.org

--- Comment #5 from Nathan Sidwell  ---
We're turning 'ab's initializer into a static one (so the lack of a dynamic
initializer is a red herring).  But we're flubbing the form of that initializer
because the placement of AB's bases is not their declaration order.  B is
chosen as the primary base, so AB is laid out as:
AB size 24 align 8
  A @ 16
  B @ 0

The  emitted initializer is:
_ZL2ab:
.zero   16
.long   1  <-- A::a
.quad   _ZTV2AB+16
.quad   2  <-- B::element

(I modified the testcase so the NSDMIs are distinct non-zero values).  The 16
zero bytes appear to be skipping over the B sub-object to place A's
initializer.

We should be emitting something more like:

_ZL2ab:
.quad   _ZTV2AB+16
.quad   2  <--B::element
.long   1  <-- A::a
.zero   4  <-- tail padding

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-24 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka  ---
(In reply to Jakub Jelinek from comment #2)
> Started with r217664.

I assume that's with -std=c++11?  I wonder which commit introduced the
regression when the test case is compiled with -std=c++14.

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-24 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

--- Comment #4 from Jakub Jelinek  ---
Yeah, that was with -std=c++0x.  With -std=c++1y it started one revision
earlier (r217663).

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-24 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org
   Target Milestone|--- |5.4

--- Comment #2 from Jakub Jelinek  ---
Started with r217664.

[Bug c++/70393] [5/6 Regression] Miscompilation: missing constructor call for static object

2016-03-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70393

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-03-24
  Known to work||4.9.3
Summary|Miscompilation: missing |[5/6 Regression]
   |constructor call for static |Miscompilation: missing
   |object  |constructor call for static
   ||object
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
ubsan prints lots of errors confirming that the vptr is not setup up correctly.