[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

Jonathan Wakely  changed:

   What|Removed |Added

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

--- Comment #9 from Jonathan Wakely  ---
And on the branches too, for 8.4 and 9.2.

[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

--- Comment #8 from Jonathan Wakely  ---
Author: redi
Date: Mon May 20 13:04:39 2019
New Revision: 271418

URL: https://gcc.gnu.org/viewcvs?rev=271418=gcc=rev
Log:
PR c++/90532 Ensure __is_constructible(T[]) is false

An array of an unknown bound is an incomplete type, so no object of such
a type can be constructed. This means __is_constructible should always
be false for an array of unknown bound.

This patch also changes the std::is_default_constructible trait to use
std::is_constructible, which now gives the right answer for arrays of
unknown bound.

gcc/cp:

Backported from mainline
2019-05-20  Jonathan Wakely  

PR c++/90532 Ensure __is_constructible(T[]) is false
* method.c (is_xible_helper): Return error_mark_node for construction
of an array of unknown bound.

gcc/testsuite:

Backported from mainline
2019-05-20  Jonathan Wakely  

PR c++/90532 Ensure __is_constructible(T[]) is false
* g++.dg/ext/90532.C: New test.

libstdc++-v3:

Backported from mainline
2019-05-20  Jonathan Wakely  

PR c++/90532 Ensure __is_constructible(T[]) is false
* include/std/type_traits (__do_is_default_constructible_impl)
(__is_default_constructible_atom, __is_default_constructible_safe):
Remove.
(is_default_constructible): Use is_constructible.
* testsuite/20_util/is_constructible/value.cc: Check int[] case.
* testsuite/20_util/is_default_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_default_constructible/value.cc:
Likewise.

Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/ext/90532.C
Modified:
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/method.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog
branches/gcc-8-branch/libstdc++-v3/ChangeLog
branches/gcc-8-branch/libstdc++-v3/include/std/type_traits
   
branches/gcc-8-branch/libstdc++-v3/testsuite/20_util/is_constructible/value.cc
   
branches/gcc-8-branch/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc
   
branches/gcc-8-branch/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
   
branches/gcc-8-branch/libstdc++-v3/testsuite/20_util/is_trivially_default_constructible/value.cc

[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

--- Comment #7 from Jonathan Wakely  ---
Author: redi
Date: Mon May 20 13:02:10 2019
New Revision: 271417

URL: https://gcc.gnu.org/viewcvs?rev=271417=gcc=rev
Log:
PR c++/90532 Ensure __is_constructible(T[]) is false

An array of an unknown bound is an incomplete type, so no object of such
a type can be constructed. This means __is_constructible should always
be false for an array of unknown bound.

This patch also changes the std::is_default_constructible trait to use
std::is_constructible, which now gives the right answer for arrays of
unknown bound.

gcc/cp:

Backported from mainline
2019-05-20  Jonathan Wakely  

PR c++/90532 Ensure __is_constructible(T[]) is false
* method.c (is_xible_helper): Return error_mark_node for construction
of an array of unknown bound.

gcc/testsuite:

Backported from mainline
2019-05-20  Jonathan Wakely  

PR c++/90532 Ensure __is_constructible(T[]) is false
* g++.dg/ext/90532.C: New test.

libstdc++-v3:

Backported from mainline
2019-05-20  Jonathan Wakely  

PR c++/90532 Ensure __is_constructible(T[]) is false
* include/std/type_traits (__do_is_default_constructible_impl)
(__is_default_constructible_atom, __is_default_constructible_safe):
Remove.
(is_default_constructible): Use is_constructible.
* testsuite/20_util/is_constructible/value.cc: Check int[] case.
* testsuite/20_util/is_default_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_default_constructible/value.cc:
Likewise.

Added:
branches/gcc-9-branch/gcc/testsuite/g++.dg/ext/90532.C
Modified:
branches/gcc-9-branch/gcc/cp/ChangeLog
branches/gcc-9-branch/gcc/cp/method.c
branches/gcc-9-branch/gcc/testsuite/ChangeLog
branches/gcc-9-branch/libstdc++-v3/ChangeLog
branches/gcc-9-branch/libstdc++-v3/include/std/type_traits
   
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/is_constructible/value.cc
   
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc
   
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
   
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/is_trivially_default_constructible/value.cc

[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

--- Comment #6 from Jonathan Wakely  ---
Fixed on trunk so far.

[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

--- Comment #5 from Jonathan Wakely  ---
Author: redi
Date: Mon May 20 11:32:51 2019
New Revision: 271412

URL: https://gcc.gnu.org/viewcvs?rev=271412=gcc=rev
Log:
PR c++/90532 Ensure __is_constructible(T[]) is false

An array of an unknown bound is an incomplete type, so no object of such
a type can be constructed. This means __is_constructible should always
be false for an array of unknown bound.

This patch also changes the std::is_default_constructible trait to use
std::is_constructible, which now gives the right answer for arrays of
unknown bound.

gcc/cp:

PR c++/90532 Ensure __is_constructible(T[]) is false
* method.c (is_xible_helper): Return error_mark_node for construction
of an array of unknown bound.

gcc/testsuite:

PR c++/90532 Ensure __is_constructible(T[]) is false
* g++.dg/ext/90532.C: New test.

libstdc++-v3:

PR c++/90532 Ensure __is_constructible(T[]) is false
* include/std/type_traits (__do_is_default_constructible_impl)
(__is_default_constructible_atom, __is_default_constructible_safe):
Remove.
(is_default_constructible): Use is_constructible.
* testsuite/20_util/is_constructible/value.cc: Check int[] case.
* testsuite/20_util/is_default_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_constructible/value.cc: Likewise.
* testsuite/20_util/is_trivially_default_constructible/value.cc:
Likewise.

Added:
trunk/gcc/testsuite/g++.dg/ext/90532.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/method.c
trunk/gcc/testsuite/ChangeLog
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/type_traits
trunk/libstdc++-v3/testsuite/20_util/is_constructible/value.cc
trunk/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc
trunk/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
   
trunk/libstdc++-v3/testsuite/20_util/is_trivially_default_constructible/value.cc

[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #4 from Jonathan Wakely  ---
Patch posted: https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01226.html

[Bug c++/90532] [8/9/10 Regression] is_constructible_v and is_default_constructible_v should agree

2019-05-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90532

Jonathan Wakely  changed:

   What|Removed |Added

  Known to work||7.4.0
   Target Milestone|--- |8.4
Summary|is_constructible_v   |[8/9/10 Regression]
   |and |is_constructible_v
   |is_default_constructible_v< |and
   |int[]> should agree |is_default_constructible_v<
   ||int[]> should agree
  Known to fail||10.0, 8.1.0, 8.3.0, 9.1.0

--- Comment #3 from Jonathan Wakely  ---
This is a regression due to the addition of the __is_constructible built-in.
Before we had that, this correct test passed:

#include 

static_assert( !std::is_constructible::value, "");
static_assert( !std::is_default_constructible::value, "");

static_assert( !std:: is_trivially_constructible::value, "");
static_assert( !std::is_trivially_default_constructible::value, "");

Now three out of four assertions fail, because they use the built-in.

I'm testing this fix:

--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1201,6 +1201,8 @@ is_xible_helper (enum tree_code code, tree to, tree from,
bool trivial)
 expr = assignable_expr (to, from);
   else if (trivial && from && TREE_CHAIN (from))
 return error_mark_node; // only 0- and 1-argument ctors can be trivial
+  else if (TREE_CODE(to) == ARRAY_TYPE && !TYPE_DOMAIN (to))
+return error_mark_node; // can't construct an array of unknown bound
   else
 expr = constructible_expr (to, from);
   return expr;