https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126719

            Bug ID: 126719
           Summary: ICE in cp_fold: tree check: accessed operand 4 of
                    call_expr with 3 operands for
                    __builtin_is_corresponding_member() with zero
                    arguments
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Keywords: ice-checking, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stuzyf at 163 dot com
  Target Milestone: ---

Reproducer:
https://godbolt.org/z/x7rh1M8vs

```
namespace std
{
template <class S1, class S2, class M1, class M2>
constexpr bool
is_corresponding_member (M1 S1::*m1, M2 S2::*m2) noexcept
{
  return __builtin_is_corresponding_member();   
}
}
struct A { int a; };
struct B;
constexpr int B::*n = nullptr;
constexpr auto a = std::is_corresponding_member (&A::a, n);     

```

Backtrace:
```
<source>: In instantiation of 'constexpr bool std::is_corresponding_member(M1
S1::*, M2 S2::*) [with S1 = A; S2 = B; M1 = int; M2 = int]':
<source>:13:49:   required from here
   13 | constexpr auto a = std::is_corresponding_member (&A::a, n);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
<source>:7:43: error: '__builtin_is_corresponding_member' needs two arguments
    7 |   return __builtin_is_corresponding_member();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
<source>:7:43: internal compiler error: tree check: accessed operand 4 of
call_expr with 3 operands in cp_fold, at cp/cp-gimplify.cc:3832
0x30c2a58 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x30b769b internal_error(char const*, ...)
        ???:0
0xa93959 tree_operand_check_failed(int, tree_node const*, char const*, int,
char const*)
        ???:0
0xfd8568 tree_operand_check(tree_node*, int, char const*, int, char const*)
        ???:0
0x1dc2fac 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
0x1dc31d0 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
0x104b673 cp_fold_function(tree_node*)
        ???:0
0x109f3c7 finish_function(bool)
        ???:0
0x124e68d instantiate_decl(tree_node*, bool, bool)
        ???:0
0x1dc2fac 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
0x1dc31d0 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
0x1dc6bb7 walk_tree_without_duplicates_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false,
default_hash_traits<tree_node*> >*))
        ???:0
0x10213b9 maybe_constant_value(tree_node*, tree_node*, mce_value)
        ???:0
0x12f65b7 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0x10a94a6 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0x11ea2d3 c_parse_file()
        ???:0
0x13777a9 c_common_parse_file()
        ???:0
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_assertions-16.1.0/bin/../libexec/gcc/x86_64-linux-gnu/16.1.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_assertions-16.1.0/bin/../lib/gcc/x86_64-linux-gnu/16.1.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -fdiagnostics-color=always
-fno-verbose-asm -o /app/output.s
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
```

Reproduced with:
```
gcc 12.1.0, x86_64, C++ mode, assertions enabled (earliest version reproduced)
gcc 16.1.0, x86_64, C++ mode, assertions enabled (version where it was
discovered)

```

Reply via email to