-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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-13 fails to compile libstdc++'s std::variant<std::vector<int>>: error: attempt to use a deleted function #52956
Comments
The errors are not the same on your reduced version. You must check for I suspect this isn't a compiler bug, per se, but how clang and gcc interpret incomplete or unimplemented types, as you can clearly see in your reduced version. |
Aha, thank you! I'm not really sure not to get better/smaller example. Filed https://gcc.gnu.org/PR103891 to possibly get some help from libstdc++ developers (and maybe fix libstdc++). |
I normally use On the GCC front, Andrew seems to have found a promising direction on what looks to be a similar issue. But I'm copying some people in case he's right about missing C++ 20 features. |
The error message is different, but the original ends with “destructor [...] is implicitly deleted because variant field Maybe @saarraz can help. Question here seems to be whether constraints should be evaluated after completing the class definition (like member function bodies) or not. Not sure where the standard would be defining that. |
Seems that [class.mem.general]p7 says that a
So I think Clang is right here. But maybe I'm missing something. |
In fact, isn't it pretty obvious that it can't be a complete-class context? Because that could affect the availability of member functions, which in turn affects some type traits. Consider the negation: template <typename> union _Variadic_union {
~_Variadic_union() requires(__has_trivial_destructor(_Variadic_union));
}; So if With noexcept specifiers Clang solves this by not allowing references to the class itself or to member functions that are declared later (so in some sense it's more of an opportunistic complete-class context): template <typename> struct X {
~X() noexcept(noexcept(X()));
static void f() noexcept(noexcept(g()));
static void g() noexcept(noexcept(f()));
};
X<int> x; produces:
|
The original code has no self-reference though: template<typename _First, typename... _Rest>
union _Variadic_union<_First, _Rest...>
{
// ...
constexpr ~_Variadic_union()
requires (!__has_trivial_destructor(_First))
|| (!__has_trivial_destructor(_Variadic_union<_Rest...>))
{ }
// ...
}; So while I think Clang is right to reject the reduction (not sure how GCC is able to compile this), the original code should be fine. And as @jwakely pointed out in the GCC bug report, it's very likely #45614. |
https://github.com/marxin/cvise is sometimes much faster than the original creduce. You can use exactly the same "interestingness test" scripts with it. |
I'm not comfortable reducing original example because libstdc++ is full of version ifdefs. I don't think I can construct plausible test for it. I'm not sure where clang++/g++ is expected to be different and where it's accidental. I'm attaching mostly selfcontained archive with minimal example and bundled libstdc++ for x86_64: src.tar.gz. I was not able to reduce it even manually as I got lost in various
|
#45614 is fixed now and the example from the initial report compiles with up to date clang/libstdc++. Closing this. |
Initially I observed the error as a
mold-1.0.0
build failure onclang-13
which uses gcc-12'slibstdc++
. Here is a one line reproducer:gcc-12
builds it fine,clang-13
fails:I attempted to shrink down preprocessed file to extract compiler difference. My result:
gcc
/clang
handling difference:The text was updated successfully, but these errors were encountered: