public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8526] c++: braced-list overload resolution [PR100963]
@ 2021-06-08 17:29 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-06-08 17:29 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5af06ce836d4d8d1654db3855db8b86a994faf49
commit r11-8526-g5af06ce836d4d8d1654db3855db8b86a994faf49
Author: Jason Merrill <jason@redhat.com>
Date: Tue Jun 8 09:19:58 2021 -0400
c++: braced-list overload resolution [PR100963]
My PR969626 patch made us ignore template candidates when there's a perfect
non-template candidate. In this case, we were considering B(int) a perfect
match for B({0}), but the brace elision makes it imperfect.
PR c++/100963
gcc/cp/ChangeLog:
* call.c (perfect_conversion_p): Check check_narrowing.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist124.C: New test.
Diff:
---
gcc/cp/call.c | 3 +++
gcc/testsuite/g++.dg/cpp0x/initlist124.C | 13 +++++++++++++
2 files changed, 16 insertions(+)
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4c4cb5d0491..4f1565dc68f 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5878,6 +5878,9 @@ perfect_conversion_p (conversion *conv)
next_conversion (conv)->type))
return false;
}
+ if (conv->check_narrowing)
+ /* Brace elision is imperfect. */
+ return false;
return true;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist124.C b/gcc/testsuite/g++.dg/cpp0x/initlist124.C
new file mode 100644
index 00000000000..45dcbb303e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist124.C
@@ -0,0 +1,13 @@
+// PR c++/100963
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+struct B {
+ B(int) = delete;
+ template<class T> B(std::initializer_list<T>);
+};
+
+int main() {
+ B({0});
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-08 17:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 17:29 [gcc r11-8526] c++: braced-list overload resolution [PR100963] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).