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-8714] c++: argument pack with expansion [PR86355]
Date: Fri,  9 Jul 2021 20:14:21 +0000 (GMT)	[thread overview]
Message-ID: <20210709201421.A6EB83AAB4A0@sourceware.org> (raw)

https://gcc.gnu.org/g:542d90bfd802274f38637aaaffc2dd1de62c9ec6

commit r11-8714-g542d90bfd802274f38637aaaffc2dd1de62c9ec6
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 26 17:38:42 2021 -0400

    c++: argument pack with expansion [PR86355]
    
    This testcase revealed that we were using PACK_EXPANSION_EXTRA_ARGS a lot
    more than necessary; use_pack_expansion_extra_args_p meant to use it in the
    case of corresponding arguments in different argument packs differing in
    whether they are pack expansions, but it was mistakenly also returning true
    for the case of a single argument pack containing both expansion and
    non-expansion elements.
    
    Surprisingly, just disabling that didn't lead to any regressions in the
    testsuite; it seems other changes have prevented us getting to this point
    for code that used to exercise it.  So this patch limits the check to
    arguments in the same position in the packs, and asserts that we never
    actually see a mismatch.
    
            PR c++/86355
    
    gcc/cp/ChangeLog:
    
            * pt.c (use_pack_expansion_extra_args_p): Don't compare
            args from the same argument pack.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/alias-decl-variadic2.C: New test.

Diff:
---
 gcc/cp/pt.c                                       |  7 +++++--
 gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C | 13 +++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 145468d5cb1..31c86328ef0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12444,9 +12444,9 @@ use_pack_expansion_extra_args_p (tree parm_packs,
       return false;
     }
 
-  bool has_expansion_arg = false;
   for (int i = 0 ; i < arg_pack_len; ++i)
     {
+      bool has_expansion_arg = false;
       bool has_non_expansion_arg = false;
       for (tree parm_pack = parm_packs;
 	   parm_pack;
@@ -12466,7 +12466,10 @@ use_pack_expansion_extra_args_p (tree parm_packs,
 	}
 
       if (has_expansion_arg && has_non_expansion_arg)
-	return true;
+	{
+	  gcc_checking_assert (false);
+	  return true;
+	}
     }
   return false;
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C
new file mode 100644
index 00000000000..4299c7e88dc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C
@@ -0,0 +1,13 @@
+// PR c++/86355
+// { dg-do compile { target c++11 } }
+
+template <int...> struct integral_constant {
+  static const int value = 1;
+};
+template <class... T> using mp_all = integral_constant<T::value...>;
+template <class... T> using check2 = mp_all<mp_all<T..., integral_constant<0>>>;
+check2<> x;
+
+template <class T, class U> struct assert_same;
+template <class T> struct assert_same<T,T> { };
+assert_same<decltype(x),integral_constant<1>> a;


                 reply	other threads:[~2021-07-09 20:14 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=20210709201421.A6EB83AAB4A0@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).