public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "arthur.j.odwyer at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/109017] New: ICE on unexpanded pack from C++20 explicit-template-parameter lambda syntax
Date: Fri, 03 Mar 2023 20:51:24 +0000	[thread overview]
Message-ID: <bug-109017-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109017
           Summary: ICE on unexpanded pack from C++20
                    explicit-template-parameter lambda syntax
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/bdT84P318
template<class...>
struct A {
    static void g() {
        int dummy[] = {
            []<class... Ts>(Ts... ts){
                int i = Ts();
            } ...
        };
    }
};
int main() {
    A<int>::g();
}


<source>: In instantiation of 'static void A< <template-parameter-1-1> >::g()
[with <template-parameter-1-1> = {int}]':
<source>:12:14:   required from here
<source>:4:13: internal compiler error: in tsubst_pack_expansion, at
cp/pt.cc:13388
    4 |         int dummy[] = {
      |             ^~~~~
0x247a53e internal_error(char const*, ...)
        ???:0
0xae95dc fancy_abort(char const*, int, char const*)
        ???:0
0xd09f45 instantiate_decl(tree_node*, bool, bool)
        ???:0
0xd362db instantiate_pending_templates(int)
        ???:0
0xbe4555 c_parse_final_cleanups()
        ???:0
0xe21948 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


Apparently GCC fails to recognize the `class... Ts` in the angle brackets (new
syntax in C++20) as pertaining to the lambda itself, and not to the outer
scope. So when GCC sees an unexpanded `Ts` in the inner scope, GCC happily
accepts it (and then ICEs). Notice that if you change `Ts()` to `ts` in the
inner scope, GCC correctly rejects the code with the usual "parameter packs not
expanded" error. The ICE is triggered specifically by misuse of
`Ts`-from-the-new-in-C++20-syntax.

             reply	other threads:[~2023-03-03 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 20:51 arthur.j.odwyer at gmail dot com [this message]
2023-03-04 16:22 ` [Bug c++/109017] " hiraditya at msn dot com
2023-03-06  8:28 ` rguenth at gcc dot gnu.org
2023-03-07 14:53 ` [Bug c++/109017] ICE on unexpanded pack from C++20 explicit-template-parameter lambda syntax since r8-7648-g8859913ea3cbefdc marxin 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-109017-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).