public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1299] c++: braced-list overload resolution [PR100963]
@ 2021-06-08 17:28 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-06-08 17:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:91349e57bbfd010156b9128b2ad751c8843e7245

commit r12-1299-g91349e57bbfd010156b9128b2ad751c8843e7245
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 17fc60cd4af..d2f6ca872fc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5880,6 +5880,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:28 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:28 [gcc r12-1299] 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).