[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-04-21 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Jonathan Wakely :

https://gcc.gnu.org/g:d76925e46fad09fc9be6759cbf1f23c9a8344dbf

commit r10-7856-gd76925e46fad09fc9be6759cbf1f23c9a8344dbf
Author: Jonathan Wakely 
Date:   Tue Apr 21 22:18:51 2020 +0100

libstdc++: Support arrays in std::is_nothrow_constructible (PR 94149)

The front end now supports parenthesized initialization for arrays in
C++20, so extend std::is_nothrow_constructible to support them too.

gcc/testsuite:

PR c++/94149
* g++.dg/cpp2a/paren-init24.C: Fix FIXMEs.

libstdc++-v3:

PR c++/94149
* include/std/type_traits (__is_nt_constructible_impl): Add partial
specializations for bounded arrays with non-empty initializers.
* testsuite/20_util/is_nothrow_constructible/value_c++20.cc: New
test.

[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-04-10 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #6 from Marek Polacek  ---
Fixed.

[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-04-10 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:62c25d7adb1a5664982449dda0e7f9ca63cf4735

commit r10-7681-g62c25d7adb1a5664982449dda0e7f9ca63cf4735
Author: Marek Polacek 
Date:   Thu Apr 9 16:31:59 2020 -0400

c++: make __is_constructible work with paren-init of aggrs [PR94149]

In C++20 this is well-formed:

  using T = int[2];
  T t(1, 2);

which means that std::is_constructible_v should be true.
But constructible_expr immediately returned the error_mark_node when it
saw a list with more than one element.  To give accurate results in
C++20, we have to try initializing the aggregate from a parenthesized list
of
values.

To not repeat the same mistake as in c++/93790, if there's only one
element, I'm trying {} only when () didn't succeed.  is_constructible5.C
verifies this.

In paren-init24.C std::is_nothrow_constructible_v doesn't work due to
 error: invalid 'static_cast' from type 'int' to type 'int [1]'
and
 error: functional cast to array type 'int [2]'

This needs to be fixed in libstdc++.

PR c++/94149
* method.c (constructible_expr): In C++20, try using parenthesized
initialization of aggregates to determine the result of
__is_constructible.

* g++.dg/cpp2a/paren-init24.C: New test.
* g++.dg/cpp2a/paren-init25.C: New test.
* g++.dg/ext/is_constructible5.C: New test.

[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-04-09 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch, rejects-valid

--- Comment #4 from Marek Polacek  ---
Patch posted:


[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-03-11 Thread ville.voutilainen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

Ville Voutilainen  changed:

   What|Removed |Added

 CC||ville.voutilainen at gmail dot 
com

--- Comment #3 from Ville Voutilainen  ---
(In reply to Marek Polacek from comment #2)
> C++20 paren-init -> mine.

This goes from constructible_expr into
perform_direct_initialization_if_possible, which then goes into
implicit_conversion, which fails to build a conversion.

[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-03-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #2 from Marek Polacek  ---
C++20 paren-init -> mine.

[Bug c++/94149] __is_constructible doesn't know about C++20 parenthesized init for arrays

2020-03-11 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94149

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-03-11
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
And of course __is_constructible(int[3], int, int) should work too.