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

            Bug ID: 127458
           Summary: tree check ICE on call of templated function with
                    packed type and non-type parameters
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: benjsith at gmail dot com
  Target Milestone: ---

The following C++ code, compiled with -std=c++20

template<typename... T, T... V> void g(const T (&...p)[V]) { }
void test() { g({1, 2, 3}, {{}}); }

will ICE (full text in attachment):
internal compiler error: tree check: expected type_argument_pack or
nontype_argument_pack, have integer_type in unify_pack_expansion, at
cp/pt.cc:26105

Clang compiles it w/o errors, and my understanding is the code is valid.
Godbolt link: https://godbolt.org/z/T9bPM75x3

I locally built GCC from commit fea8a2b9bf26f654ec0b97d43259dad5b0275c00 Here
is the -v output:

Using built-in specs.
COLLECT_GCC=./../local-bins/bin/g++
COLLECT_LTO_WRAPPER=/home/benji/Dev/3rdParty/gcc/local-bins/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./../gcc/configure
--prefix=/home/benji/Dev/3rdParty/gcc/local-bins --enable-languages=c,c++
--disable-multilib --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260917 (experimental) (GCC)

I also repro'd it going back to GCC 10.x: I think it's been present since C++20
was supported, so I don't think a bisect would say much

For disclosure: this was found by having an LLM generate several torture test
cases for C++ templates, originally for testing Clang. However, I manually
confirmed the repro on GCC trunk, and minimised it

Reply via email to