]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: 'new T[N]' and SFINAE [PR82110]
authorPatrick Palka <ppalka@redhat.com>
Sat, 10 Jul 2021 02:40:07 +0000 (22:40 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 10 Jul 2021 02:40:07 +0000 (22:40 -0400)
commitb9119edc09e4660d772dea771578715858f7fbdb
tree4b3c6fb7575e670996de09c0ae666b7b472a1098
parentef2ace642a1ba795235c542b728cb83c73dfce74
c++: 'new T[N]' and SFINAE [PR82110]

Here we're failing to treat 'new T[N]' as erroneous in a SFINAE context
when T isn't default constructible because expand_aggr_init_1 doesn't
communicate to build_aggr_init (its only SFINAE caller) whether the
initialization was actually successful.  To fix this, this patch makes
expand_aggr_init_1 and its subroutine expand_default_init return true on
success, false on failure so that build_aggr_init can properly return
error_mark_node on failure.

PR c++/82110

gcc/cp/ChangeLog:

* init.c (build_aggr_init): Return error_mark_node if
expand_aggr_init_1 returns false.
(expand_default_init): Change return type to bool.  Return false
on error, true on success.
(expand_aggr_init_1): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/pr78765.C: Expect another conversion failure
diagnostic.
* g++.dg/template/sfinae14.C: Flip incorrect assertion.
* g++.dg/cpp2a/concepts-requires27.C: New test.
gcc/cp/init.c
gcc/testsuite/g++.dg/cpp0x/pr78765.C
gcc/testsuite/g++.dg/cpp2a/concepts-requires27.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/sfinae14.C