-
Notifications
You must be signed in to change notification settings - Fork 11k
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-19 returns true for __is_literal_type
on union with non trivial member starting with C++-23
#85550
Comments
@llvm/issue-subscribers-clang-frontend Author: None (AMS21)
Given the following code
struct non_trivial {
~non_trivial();
};
union non_trivial_union {
int i;
non_trivial n;
};
static_assert(!__is_literal_type(non_trivial), "");
static_assert(!__is_literal_type(non_trivial_union), ""); clang-18.1.0 compiles fine while clang-19 fails the second Note that this does not happen in C++-20 mode godbolt |
Just took another look at my test code and there seems to be a lot of disagreement if this type is literal or not. gcc before 10.0 says it's always: not literal With that and the fact that |
__is_literal_type
on union with non trivial member with C++-23+__is_literal_type
on union with non trivial member starting with C++-23
Seems related to #77753. The implicitly declared destructor of |
That would explain the discrepancy, yeah. I’d leave the issue open in case I either misread the standard and the type is in fact not supposed to be literal (because we currently think it is, except in C++23 mode, apparently) or in case we do decide to do something about this. |
I think it works as expected in C++23 mode. Union with at least one literal member is literal. The fact why it is not considered literal by clang in C++20 mode is the destructor. If a class doesn't have a |
Given the following code
clang-18.1.0 compiles fine while clang-19 fails the second
static_assert
.godbolt
Note that this does not happen in C++-20 mode godbolt
The text was updated successfully, but these errors were encountered: