[clang] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)
Amy Huang via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 13:12:30 PDT 2024
amykhuang wrote:
Hi, this is causing failures for Chrome, building with c++20:
```
$ cat t.cc
template <typename Type> class StrongAlias {
friend constexpr bool operator==(const StrongAlias &, const StrongAlias &) = default;
Type value;
};
class Token {};
bool operator==(const Token&, const Token&);
StrongAlias<Token> a;
$ clang -std=c++20 t.cc
t.cc:2:3: error: defaulted definition of equality comparison operator cannot be declared constexpr because it invokes a non-constexpr comparison function
2 | friend constexpr bool operator==(const StrongAlias &, const StrongAlias &) = default;
| ^
t.cc:9:20: note: in instantiation of template class 'StrongAlias<Token>' requested here
9 | StrongAlias<Token> a;
| ^
t.cc:3:8: note: non-constexpr comparison function would be used to compare member 'value'
3 | Type value;
| ^
t.cc:7:6: note: non-constexpr comparison function declared here
7 | bool operator==(const Token&, const Token&);
| ^
1 error generated.
```
https://github.com/llvm/llvm-project/pull/77753
More information about the cfe-commits
mailing list