https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104622
Bug ID: 104622 Summary: [12 Regression] ICE in compare_ics, at cp/call.cc:11419 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gs...@t-online.de Target Milestone: --- Changed between 20210822 and 20210905 : (variations of g++.dg/warn/Winvalid-memory-model*) $ cat z1.cc #include <atomic> static const std::memory_order relaxed = std::memory_order_relaxed; extern std::atomic<int> eai; void test_compare_exchange (int pi, int *pj) { #define cmpxchg(x, y, z, o1, o2) \ std::atomic_compare_exchange_weak_explicit (x, y, z, o1, o2) cmpxchg (&eai, pi++, *pj++, relaxed, relaxed); $ cat z2.cc #include <atomic> static const std::memory_order relaxed = std::memory_order_relaxed; extern std::atomic<int> eai; void test_compare_exchange (int *pi, int *pj) { #define cmpxchg(x, y, z, o1, o2) \ std::atomic_compare_exchange_weak_explicit (x, -1, z, o1, o2) cmpxchg (&eai, pi++, *pj++, relaxed, relaxed); $ cat z3.cc #include <atomic> static const std::memory_order relaxed = std::memory_order_relaxed; static const std::memory_order consume = std::memory_order_consume; extern std::atomic<int> eai; void test_compare_exchange (int *pi, int *pj) { #define cmpxchg(x, y, z, o1, o2) \ std::atomic_compare_exchange_weak_explicit (x, y, z, o1, o2) cmpxchg (&eai,*pj++,*pj++, relaxed, consume); $ g++-12-20220220 -c z1.cc z1.cc: In function 'void test_compare_exchange(int, int*)': z1.cc:7:46: internal compiler error: Segmentation fault 7 | std::atomic_compare_exchange_weak_explicit (x, y, z, o1, o2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ z1.cc:8:3: note: in expansion of macro 'cmpxchg' 8 | cmpxchg (&eai, pi++, *pj++, relaxed, relaxed); | ^~~~~~~ 0xda25ef crash_signal ../../gcc/toplev.cc:322 0x6d06ee compare_ics ../../gcc/cp/call.cc:11419 0x6d747a joust ../../gcc/cp/call.cc:12083 0x6d857d tourney ../../gcc/cp/call.cc:12523 0x6d86c6 perform_overload_resolution ../../gcc/cp/call.cc:4718 0x6dd4b2 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ../../gcc/cp/call.cc:4816 0x85c0c0 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ../../gcc/cp/semantics.cc:2870 0x7f33af cp_parser_postfix_expression ../../gcc/cp/parser.cc:7878 0x805841 cp_parser_unary_expression ../../gcc/cp/parser.cc:9035 0x7dcc5f cp_parser_cast_expression ../../gcc/cp/parser.cc:9939 0x7dd492 cp_parser_binary_expression ../../gcc/cp/parser.cc:10041 0x7ddbe0 cp_parser_assignment_expression ../../gcc/cp/parser.cc:10345 0x7dea6c cp_parser_expression ../../gcc/cp/parser.cc:10515 0x7e1587 cp_parser_expression_statement ../../gcc/cp/parser.cc:12711 0x7eecf1 cp_parser_statement ../../gcc/cp/parser.cc:12507 0x7efcb4 cp_parser_statement_seq_opt ../../gcc/cp/parser.cc:12856 0x7efd6f cp_parser_compound_statement ../../gcc/cp/parser.cc:12808 0x80de98 cp_parser_function_body ../../gcc/cp/parser.cc:25062 0x80de98 cp_parser_ctor_initializer_opt_and_function_body ../../gcc/cp/parser.cc:25113 0x80e356 cp_parser_function_definition_after_declarator ../../gcc/cp/parser.cc:31243