https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123337
Bug ID: 123337
Summary: ICE: Segmentation fault in build_new_op when assigning
to an oversized explicit register variable
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/hh6ecrTo9
When I am trying to assign a larger struct directly to a variable that is bound
to a specific register (like rdx) and the structure is too large to fit into a
single register. However, this triggers the crash.
Program:
```c
struct S { int a[6]; };
S foo();
int main() {
register S s __asm__("rdx");
s = foo();
}
```
Traceback:
```console
<source>:6:13: error: address of explicit register variable 's' requested
6 | s = foo();
| ^
<source>:6:13: internal compiler error: Segmentation fault
0x290fae8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29048ab internal_error(char const*, ...)
???:0
0xb4dfa6 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
???:0
0xe3ac69 cp_build_modify_expr(unsigned long, tree_node*, tree_code, tree_node*,
int)
???:0
0xe3b457 build_x_modify_expr(unsigned long, tree_node*, tree_code, tree_node*,
tree_node*, int)
???:0
0xd52ed3 c_parse_file()
???:0
0xec4909 c_common_parse_file()
???:0
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.
Compiler returned: 1
```