Bug 120262 - internal compiler error: in remap_type_1 since version 12.1
Summary: internal compiler error: in remap_type_1 since version 12.1
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 16.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, ice-on-invalid-code
Depends on:
Blocks: C++VLA
  Show dependency tree / graph
 
Reported: 2025-05-13 17:57 UTC by MARIO RODRIGUEZ BEJAR
Modified: 2025-05-15 03:36 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-05-13 00:00:00


Attachments
Reduced testcase (90 bytes, text/plain)
2025-05-13 18:49 UTC, Drea Pinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MARIO RODRIGUEZ BEJAR 2025-05-13 17:57:50 UTC
The following code ICE in <source>:16:5: internal compiler error: in remap_type_1, at tree-inline.cc:575

```
#include <iostream>
int main()
{
    using namespace std::string_literals;
    auto matrix = [] {
        int n, m;
        int matrix [m][n];
        for (size_t i = 0; i < 2; ++i)
        {
            for (size_t j = 0; j < 2; ++j)
            {
                std::cin >> matrix[i][j];
            }
        }
        return matrix;
    }();
}
```

Stack dump

```
<source>: In static member function 'static constexpr int (* main()::<lambda()>::_FUN())[n]':
<source>:16:5: internal compiler error: in remap_type_1, at tree-inline.cc:575
   16 |     }();
      |     ^
0x2941455 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t)
	???:0
0x295e656 internal_error(char const*, ...)
	???:0
0xada8ac fancy_abort(char const*, int, char const*)
	???:0
0x14fdc02 remap_type(tree_node*, copy_body_data*)
	???:0
0x14fdc02 remap_type(tree_node*, copy_body_data*)
	???:0
0x1500951 copy_tree_body_r(tree_node**, int*, void*)
	???:0
0x180800c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
	???:0
0x1808208 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
	???:0
0x14fe92d copy_fn(tree_node*, tree_node*&, tree_node*&)
	???:0
0xb56c85 maybe_save_constexpr_fundef(tree_node*)
	???:0
0xbca98f finish_function(bool)
	???:0
0xc160ca maybe_add_lambda_conv_op(tree_node*)
	???:0
0xcfead3 c_parse_file()
	???:0
0xe614f9 c_common_parse_file()
	???:0
```

To reproduce:

https://godbolt.org/z/aEzTha1hs
Comment 1 Drea Pinski 2025-05-13 18:43:11 UTC
This code should be rejected as returning an pointer to a VLA type is questionable.
Comment 2 Drea Pinski 2025-05-13 18:49:27 UTC
Created attachment 61418 [details]
Reduced testcase