================ @@ -0,0 +1,115 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +struct A { + int a, b[3], c; + bool operator==(const A&) const = default; +}; + +constexpr auto a0 = A{0, 0, 3, 4, 5}; + +// expected-note@+1 {{evaluates to 'A{0, {0, 3, 4}, 5} == A{1, {2, 3, 4}, 5}'}} +static_assert(a0 == A{1, {2, 3, 4}, 5}); // expected-error {{failed}} + +struct _arr { + const int b[3]; + constexpr bool operator==(const int rhs[3]) const { + for (unsigned i = 0; i < sizeof(b) / sizeof(int); i++) + if (b[i] != rhs[i]) + return false; + return true; + } +}; + +// expected-note@+1 {{{evaluates to '_arr{{2, 3, 4}} == (int[3]){0, 3, 4}'}}} +static_assert(_arr{2, 3, 4} == a0.b); // expected-error {{failed}} ---------------- sethp wrote:
this also doesn't quite work as advertised, either. The closest I could come was something like: ``` constexpr int v[3] = {0, 3, 4}; static_assert(_arr{{2, 3, 4}} == v); // -> constexpr int v[3] = {0}; static_assert(_arr{{2}} == v); ``` Because anything else and the evaluator complained about invalid `constexpr` subexpressions in: ``` In call to '_arr{{2}}.operator==(&(int[3]){0}[0])' ``` https://github.com/llvm/llvm-project/pull/74852 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits