-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang] __is_trivially_assignable returning true with deleted member #90605
Comments
@llvm/issue-subscribers-clang-frontend Author: Nikolas Klauser (philnik777)
In C++03, Clang claims that a struct containing a member with a deleted assignment operator is assignable, but diagnoses the instantiation as using a deleted function.
struct Element {
Element& operator=(const Element&) = delete;
};
struct S {
Element i;
S& operator=(const S&) = default;
};
_Static_assert(!__is_trivially_assignable(S&, const S&)); // assertion fails
_Static_assert(!__is_assignable(S&, const S&)); // assertion fails
void test() {
S s;
S s2;
s2 = s; // diagnosed as an error
} |
@cor3ntin CWG17234 is not entirely related because it's about |
…xtension in C++03 Fixes llvm#90605
@MitalAshok Thanks. I've read the test incorrectly initially... |
So a smaller example: struct X {
X() : v(0) {}
const int v;
X& operator=(const X&) = default;
};
_Static_assert(__is_assignable(X&, const X&));
int main() {
X x1;
const X x2;
x1 = x2; // Error is here
} The One thing we can do is make |
I would much rather try to make this C++11-extension-in-C++03 work as closely as possible to the way it works in C++11. So my vote would go for fixing Clang so that it considers |
In C++03, Clang claims that a struct containing a member with a deleted assignment operator is assignable, but diagnoses the instantiation as using a deleted function.
(Godbolt)
The text was updated successfully, but these errors were encountered: