public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "davidfromonline at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107853] New: Cannot create friend function template with variadic pack that depends on variadic pack
Date: Wed, 23 Nov 2022 23:39:30 +0000	[thread overview]
Message-ID: <bug-107853-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107853

            Bug ID: 107853
           Summary: Cannot create friend function template with variadic
                    pack that depends on variadic pack
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davidfromonline at gmail dot com
  Target Milestone: ---

The following valid translation unit

```
template<typename, typename>
concept c = true;

template<typename... Ts>
struct s {
        template<typename... Us> requires (... and c<Us, Ts>)
        friend void f(Us...) {
        }
};

auto x = s<>();
```

is rejected by gcc with the error message


```
<source>: In instantiation of 'struct s<>':
<source>:11:14:   required from here
<source>:6:27: error: mismatched argument pack lengths while expanding 'c<Us,
Ts>'
    6 |         template<c<Ts>... Us>
      |                           ^~
Compiler returned: 1
```

See it live: https://godbolt.org/z/4qGKP9K9a

Note that adding a single template parameter to the instantiated `s`, for
instance, `s<int>`, causes gcc to ICE:

```
template<typename, typename>
concept c = true;

template<typename... Ts>
struct s {
        template<typename... Us> requires (... and c<Us, Ts>)
        friend void f(Us...) {
        }
};

auto x = s<int>();
```

```
<source>: In instantiation of 'struct s<int>':
<source>:11:17:   required from here
<source>:6:52: internal compiler error: in use_pack_expansion_extra_args_p, at
cp/pt.cc:12674
    6 |         template<typename... Us> requires (... and c<Us, Ts>)
      |                                           ~~~~~~~~~^~~~~~~~~~
0x22f921e internal_error(char const*, ...)
        ???:0
0xa4d7bc fancy_abort(char const*, int, char const*)
        ???:0
0xac1bb0 tsubst_constraint(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xac1c99 maybe_substitute_reqs_for(tree_node*, tree_node const*)
        ???:0
0xc7e28c instantiate_class_template(tree_node*)
        ???:0
0xccdb7f complete_type_or_maybe_complain(tree_node*, tree_node*, int)
        ???:0
0xcef1a8 build_functional_cast(unsigned int, tree_node*, tree_node*, int)
        ???:0
0xc26267 c_parse_file()
        ???:0
0xd61389 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

See it live: https://godbolt.org/z/3dfvb5ov3


Using terse syntax (`template<c<Ts>... Us>`) has the same behavior.

             reply	other threads:[~2022-11-23 23:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 23:39 davidfromonline at gmail dot com [this message]
2022-11-24  1:04 ` [Bug c++/107853] Cannot create friend function template with a requires uses the " pinskia at gcc dot gnu.org
2022-11-24  1:09 ` [Bug c++/107853] [10/11/12/13 Regression] variadic template with a variadic template friend with a requires of fold expression pinskia at gcc dot gnu.org
2022-12-21  9:52 ` rguenth at gcc dot gnu.org
2022-12-21 16:09 ` ppalka at gcc dot gnu.org
2022-12-21 16:09 ` ppalka at gcc dot gnu.org
2022-12-21 16:10 ` ppalka at gcc dot gnu.org
2022-12-23 14:18 ` cvs-commit at gcc dot gnu.org
2022-12-23 14:19 ` [Bug c++/107853] [10/11/12 " ppalka at gcc dot gnu.org
2023-03-07  2:18 ` cvs-commit at gcc dot gnu.org
2023-04-05 20:16 ` mpolacek at gcc dot gnu.org
2023-04-06 13:25 ` [Bug c++/107853] [10/11 " ppalka at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c++/107853] [11 " rguenth at gcc dot gnu.org

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=bug-107853-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).