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

            Bug ID: 114292
           Summary: ICE with a lambda capturing a constant for VLA
                    allocation
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: franckbehaghel_gcc at protonmail dot com
  Target Milestone: ---

cat main.cpp

void process_tile( int tile_cols)
{
    constexpr int tile_rows = 4;

    auto lambda = [&](auto param1) {

        // Define an tmp buffer.
        float buffer[tile_rows * tile_cols]  ;

    };

    int param1=0;
    lambda(param1);

}

int main(int, const char**) {

    int tile_cols = 4;
    process_tile(tile_cols);

    return 0;
}

g++ --version 
g++ (GCC) 14.0.1 20240307 (experimental)

g++ main.cpp
main.cpp: In instantiation of ‘process_tile(int)::<lambda(auto:1)> [with auto:1
= int]’:
main.cpp:14:11:   required from here
   14 |     lambda(param1);
      |     ~~~~~~^~~~~~~~
main.cpp:9:22: internal compiler error: in tsubst_expr, at cp/pt.cc:21412
    9 |         float buffer[tile_rows * tile_cols]  ;
      |                      ^~~~~~~~~
0x778cc4 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:21412
0x967c7a tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:20082
0x969973 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:20297
0x96eb39 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:16278
0x96ee98 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.cc:16723
0x97e712 tsubst_decl
        ../../gcc/gcc/cp/pt.cc:15532
0x978e8e tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18524
0x977905 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18393
0x977905 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18780
0x977847 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18393
0x977847 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18407
0x977905 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18393
0x977905 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:18780
0x9760e6 tsubst_stmt
        ../../gcc/gcc/cp/pt.cc:27065
0x9760e6 instantiate_body
        ../../gcc/gcc/cp/pt.cc:27065
0x97688e instantiate_decl(tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.cc:27350
0x8732af maybe_instantiate_decl(tree_node*)
        ../../gcc/gcc/cp/decl2.cc:5616
0x8732af maybe_instantiate_decl(tree_node*)
        ../../gcc/gcc/cp/decl2.cc:5603
0x8742f5 mark_used(tree_node*, int)
        ../../gcc/gcc/cp/decl2.cc:5915
0x7e283a build_over_call
        ../../gcc/gcc/cp/call.cc:10563
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.

Reply via email to