-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Wrapper std::any not copy constructible #40268
Comments
This bug also effects version 6 and 7. I filed this as a question on stack overflow (https://stackoverflow.com/questions/55107458/problem-trying-to-call-copy-constructor-in-base-class-which-has-a-stdany-const) before realizing it was actually a bug. Now I'm stuck using gcc until it's fixed. :-( |
Correcting 'enhancement' to 'normal' issue. This ain't a feature request. |
I suspect this is not a bug. I expect what's happening is this:
So computation of Note that GCC trunk now rejects this code in the same way that Clang does, as the godbolt link in comment#0 shows. (Clang with -stdlib=libc++ happens to accept it, but I think we're just getting lucky there and don't happen to look at The best fix is probably to constrain the template<typename T,
typename = std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>, V>>>
V(T &&t) : a{std::forward<T>(t)} {} Such "don't consider this for copying!" constraints are generally needed when writing converting constructors that convert from anything. |
@Richard: I see the argument for constraining this code the way you suggest. However, I don't see why this code shouldn't compile. |
Probably the same issue:
It is accepted in Clang 13, but not in Clang trunk. The error is
|
Extended Description
Following is a reduction of an MSVC usage.
Following code compiles with GGC/MSVC, not with clang: https://gcc.godbolt.org/z/ii2e2E
t.cpp
run.sh
clang++ -O0 -std=c++17 -w -Wunused-variable t.cpp
The text was updated successfully, but these errors were encountered: