[Bug c++/122374] ICE on assignment expression in requires clause of copy constructor
eczbek.void at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Oct 22 15:33:39 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122374
--- Comment #1 from eczbek.void at gmail dot com ---
This might be related? Invalid example but causes a segfault:
https://godbolt.org/z/z3v1fazdT
```
template<int x>
struct S {
S() {}
void operator=(int) {}
S(const S&) requires(!requires { this->operator=(0); }) {}
};
int main() {
S<0> a;
auto b = a;
}
```
```
<source>: In function 'int main()':
<source>:12:18: error: no matching function for call to 'S<0>::S(S<0>&)'
12 | auto b = a;
| ^
• there are 2 candidates
• candidate 1: 'S<x>::S(const S<x>&) requires
!requires{((S<x>*)this)->.S<x>::operator=(int)(0);} [with int x = 0]'
<source>:7:9:
7 | S(const S&) requires(!requires { this->operator=(0); })
{}
| ^
• constraints not satisfied
• <source>: In instantiation of 'S<x>::S(const S<x>&) requires
!requires{((S<x>*)this)->.S<x>::operator=(int)(0);} [with int x = 0]':
• required from here
<source>:12:11:
12 | auto b = a;
| ^
• required by the constraints of 'template<int x> S<x>::S(const S<x>&)
requires !requires{((S<x>*)this)->.S<x>::operator=(int)(0);}'
<source>:7:2:
7 | S(const S&) requires(!requires { this->operator=(0);
}) {}
| ^
• internal compiler error: Segmentation fault
<source>:7:56:
7 | S(const S&) requires(!requires { this->operator=(0);
}) {}
| ~~~~~~~~~~~~~~^
0x28de808 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x28d35fb internal_error(char const*, ...)
???:0
0xb97786 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xb98d38 diagnose_constraints(unsigned long, tree_node*, tree_node*)
???:0
0xb288bf build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
???:0
0xb2999d build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
???:0
0xbbf408 ocp_convert(tree_node*, tree_node*, int, int, int)
???:0
0xc41fda build_aggr_init(tree_node*, tree_node*, int, int)
???:0
0xc0c83e cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
???:0
0xd3fa13 c_parse_file()
???:0
0xeb0479 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
```
More information about the Gcc-bugs
mailing list