https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119846
Bug ID: 119846 Summary: function returning vla causes ICE Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: xiaohuba2021 at 163 dot com Target Milestone: --- ``` auto f(int n, int m) { return (int(&)[n][m])m; } auto g(int n, int m) { auto b = f(n, m); b[1][1] = 0; } ``` this code (invalid) causes ICE on trunk. Compiler outputs with `-freport-bug`: ``` <source>: In function 'auto f(int, int)': <source>:2:12: warning: address of local variable 'm' returned [-Wreturn-local-addr] 2 | return (int(&)[n][m])m; | ^~~~~~~~~~~~~~~ <source>:1:19: note: declared here 1 | auto f(int n, int m) { | ~~~~^ during RTL pass: expand <source>: In function 'auto g(int, int)': <source>:6:8: internal compiler error: in expand_expr_real_1, at expr.cc:11485 6 | b[1][1] = 0; | ^ 0x292f045 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x2946016 internal_error(char const*, ...) ???:0 0xad0ad4 fancy_abort(char const*, int, char const*) ???:0 0x101659a expand_expr_real_2(separate_ops const*, rtx_def*, machine_mode, expand_modifier) ???:0 0x1020cd3 expand_expr_real_gassign(gassign*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ???:0 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Preprocessed source stored into /tmp/cctVglkh.out file, please attach this to your bugreport. Compiler returned: 1 ```