From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: array bound partial ordering [PR108390]
Date: Wed, 22 Mar 2023 15:30:16 -0400 [thread overview]
Message-ID: <20230322193016.2560128-1-jason@redhat.com> (raw)
Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
fold_convert doesn't work with a dependent argument, and problematically
differed from the corresponding fold+build_nop further down in the
function. So change it to match.
PR c++/108390
gcc/cp/ChangeLog:
* pt.cc (unify): Use fold of build_nop instead of fold_convert.
gcc/testsuite/ChangeLog:
* g++.dg/template/partial-order3.C: New test.
---
gcc/cp/pt.cc | 8 +++++---
gcc/testsuite/g++.dg/template/partial-order3.C | 6 ++++++
2 files changed, 11 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/template/partial-order3.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 056b8c7abad..90bcaa78701 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -24635,8 +24635,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
if ((strict & UNIFY_ALLOW_INTEGER)
&& TREE_TYPE (targ) && TREE_TYPE (arg)
&& CP_INTEGRAL_TYPE_P (TREE_TYPE (targ)))
- /* We're deducing from an array bound, the type doesn't matter. */
- arg = fold_convert (TREE_TYPE (targ), arg);
+ /* We're deducing from an array bound, the type doesn't matter.
+ This conversion should match the one below. */
+ arg = fold (build_nop (TREE_TYPE (targ), arg));
int x = !cp_tree_equal (targ, arg);
if (x)
unify_inconsistency (explain_p, parm, targ, arg);
@@ -24684,7 +24685,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
&& CP_INTEGRAL_TYPE_P (tparm))
/* Convert the ARG to the type of PARM; the deduced non-type
template argument must exactly match the types of the
- corresponding parameter. */
+ corresponding parameter. This conversion should match the
+ one above. */
arg = fold (build_nop (tparm, arg));
else if (uses_template_parms (tparm))
{
diff --git a/gcc/testsuite/g++.dg/template/partial-order3.C b/gcc/testsuite/g++.dg/template/partial-order3.C
new file mode 100644
index 00000000000..154505321bf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial-order3.C
@@ -0,0 +1,6 @@
+// PR c++/108390
+// { dg-do compile { target c++11 } }
+
+template<class T, T t> long f(int(*)[t], T(*)[t]);
+template<class T, int i> int f(int(*)[i], T(*)[i]) = delete;
+int n = f<int, 2>(0, 0);
base-commit: 3e791f45ded89626bc1f9f8013728f6e035801b2
--
2.31.1
reply other threads:[~2023-03-22 19:30 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=20230322193016.2560128-1-jason@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@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).