On 13 September 2018 at 12:08, Ville Voutilainen <ville.voutilai...@gmail.com> wrote: > Curses.. the resetting is over-eager; we might have a non-trivial base > or a member, and in those cases we shouldn't > reset the triviality when we see a non-user-provided const copy. I > think I'll hack around this with a non 0/1 value. :)
Testing the attached. I think it might need a comment, and I'm not sure how to word it. Here are some options: 1) /* Yo dawg, we heard you'd like another bit, so we added a second bit to your bit so you can read the other bit when you read your bit */ 2) /* I'm vewy vewy sowwy */ 3) /* We need to attach another bit to the TYPE_HAS_COMPLEX_COPY_CTOR bit, so let's quantum-entangle the additional bit and the actual bit */
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 50b60e8..ce6ac7f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13212,7 +13212,14 @@ grok_special_member_properties (tree decl) default arguments. */ TYPE_HAS_COPY_CTOR (class_type) = 1; if (user_provided_p (decl)) - TYPE_HAS_COMPLEX_COPY_CTOR (class_type) = 1; + { + if (ctor > 1) + TYPE_HAS_COMPLEX_COPY_CTOR (class_type) = 1; + else if (!TYPE_HAS_CONST_COPY_CTOR (class_type)) + TYPE_HAS_COMPLEX_COPY_CTOR (class_type) += 2; + } + else if (ctor > 1 && TYPE_HAS_COMPLEX_COPY_CTOR (class_type) == 2) + TYPE_HAS_COMPLEX_COPY_CTOR (class_type) = 0; if (ctor > 1) TYPE_HAS_CONST_COPY_CTOR (class_type) = 1; } diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible7.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible7.C new file mode 100644 index 0000000..177eb2e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible7.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++11 } } + +// PR c++/87051 + +struct M { + M(const M&) = default; + M(M&); +}; + +struct M2 { + M2(M2&); + M2(const M2&) = default; +}; + +static_assert( __is_trivially_constructible(M, M&&), ""); +static_assert( __is_trivially_constructible(M2, M2&&), "");