public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8526] c++: braced-list overload resolution [PR100963]
Date: Tue,  8 Jun 2021 17:29:08 +0000 (GMT)	[thread overview]
Message-ID: <20210608172908.875A73972017@sourceware.org> (raw)

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});
+}


                 reply	other threads:[~2021-06-08 17:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608172908.875A73972017@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).