[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-15 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |7.0

--- Comment #7 from Jason Merrill  ---
Fixed for GCC 7.

[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-15 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

--- Comment #6 from Jason Merrill  ---
Author: jason
Date: Sat Oct 15 21:25:55 2016
New Revision: 241204

URL: https://gcc.gnu.org/viewcvs?rev=241204&root=gcc&view=rev
Log:
PR c++/77945 - constexpr and trivial copy

* constexpr.c (maybe_simplify_trivial_copy): New.
(cxx_eval_store_expression): Call it.
* call.c (build_over_call): Use unsigned char for trivial copy.

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

[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-15 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||jason at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org

--- Comment #5 from Jason Merrill  ---
Yeah, implementing trivial copy with the equivalent of memcpy is fine normally,
but not in constexpr evaluation.

[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-12 Thread ville.voutilainen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

Ville Voutilainen  changed:

   What|Removed |Added

 CC||jason at redhat dot com,
   ||ville.voutilainen at gmail dot 
com

--- Comment #4 from Ville Voutilainen  ---
Another test:

struct T 
{ 
int x = 0; 
bool y = 0; 
constexpr T() {}
};

int main()
{
constexpr T t = (T{} = T{});
}

prog.cc: In function 'int main()':
prog.cc:10:31: error: accessing value of '' through a 'char [5]'
glvalue in a constant expression
 constexpr T t = (T{} = T{});
   ^

That looks rather bad.

[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-12 Thread eric at efcs dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

--- Comment #3 from Eric Fiselier  ---
> if the type contains trailing padding bytes (but one bytes between members).

The last bit is nonsense. I meant to say that padding between members seemed
OK.

[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

Jonathan Wakely  changed:

   What|Removed |Added

  Known to work|5.4.0, 6.2.0|
Summary|[7 Regression] GCC  |GCC generates invalid
   |generates invalid constexpr |constexpr copy/move
   |copy/move assignment|assignment operators for
   |operators for types with|types with trailing
   |trailing padding.   |padding.

--- Comment #2 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #1)
> 5 and 6 compile it happily.

Ugh, no they don't, sorry, I was compiling the wrong thing.

5 ICEs, 6 has the same error as 7.

[Bug c++/77945] GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.

2016-10-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-10-12
 Ever confirmed|0   |1