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

            Bug ID: 117898
           Summary: ICE: tree check: accessed elt 1 of 'tree_vec' with 0
                    elts in make_pack_index, at cp/pt.cc:4290
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---

*******************************************************************************
The compiler produces an internal error during make_pack_index when compiling
the provided code with the specified options.
The issue can also be reproduced on Compiler Explorer.

*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-241127/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/root/gdbtest/gcc/gcc-241127
--enable-languages=c,c++ --disable-multilib --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20241127 (experimental) (GCC)
*******************************************************************************
Program:
#cat code_0.cpp
void ICE(auto...args){
  [&]<int idx>(){ 
    using R = decltype( args...[idx] ) ;
  }.template operator()<0>();
}

int main( ) {
  ICE(); // empty pack
}

*******************************************************************************
Command Lines:
g++ code_0.cpp  -faggressive-loop-optimizations -funroll-loops
-fno-allocation-dce -fbranch-probabilities -fgcse -fno-strict-aliasing -fwrapv
-g -fsanitize=address  -c -o code_0.o

code_0.cpp:1:10: warning: use of ‘auto’ in parameter declaration only available
with ‘-std=c++20’ or ‘-fconcepts’ [-Wc++20-extensions]
    1 | void ICE(auto...args){
      |          ^~~~
code_0.cpp: In lambda function:
code_0.cpp:3:29: warning: pack indexing only available with ‘-std=c++2c’ or
‘-std=gnu++2c’ [-Wc++26-extensions]
    3 |     using R = decltype( args...[idx] ) ;
      |                             ^~~
code_0.cpp: In instantiation of ‘void ICE(auto:1 ...) [with auto:1 = {}]’:
code_0.cpp:8:6:   required from here
    8 |   ICE(); // empty pack
      |   ~~~^~
code_0.cpp:3:11: internal compiler error: tree check: accessed elt 1 of
‘tree_vec’ with 0 elts in make_pack_index, at cp/pt.cc:4290
    3 |     using R = decltype( args...[idx] ) ;
      |           ^
0x29c249e internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:517
0x9e31c1 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ../../gcc/gcc/tree.cc:9239
0x854f80 tree_vec_elt_check(tree_node*, int, char const*, int, char const*)
        ../../gcc/gcc/tree.h:3918
0x854f80 make_pack_index(tree_node*, tree_node*)
        ../../gcc/gcc/cp/pt.cc:4290
0xd2bfa7 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:21917
0xd260b3 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:17073
0xd3409d tsubst_decl
        ../../gcc/gcc/cp/pt.cc:15677
0xd1f01d tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18736
0xd1e139 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18990
0xd42de9 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18605
0xd42de9 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:20113
0xd2b009 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:22039
0xd2a962 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:21442
0xd2a30a tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:21057
0xd1bd20 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:19745
0xd1d1a7 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18637
0xd1e181 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18619
0xd1e139 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18990
0xd4400e tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18605
0xd4400e instantiate_body
        ../../gcc/gcc/cp/pt.cc:27403
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.

*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/nzv1x58fM

*******************************************************************************

Reply via email to