-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Transformations around noexcept
are minorly confusing
#251
Comments
Hello @Quuxplusone, thank you for bringing these two issues up.
Well, at this point it is the result of what Clang tells the implementation. There is no special case for the different special members. In your example only the default constructor is used and with that only its #include <utility>
class Foo
{
public:
Foo() = default;
};
static_assert(noexcept(Foo( Foo() )), "");
static_assert(not noexcept( new Foo() ), "");
int main()
{
Foo f;
Foo ff = f;
Foo fff = std::move(f);
} While I can see that it is confusing, at this point it is what Clang knows. One solution that comes to my mind is to completely hide unused special members. So remove everything except the default constructor in your example. Would that be less confusing for you?
I'm not sure what redundantly means here for you. Because it is compiler provided it is always class Foo
{
public:
Foo() = default;
};
int main()
{
Foo f;
} Here as a user I did not write
I agree that putting the Feel free to send a PRs for all the things. Andreas |
Yes. Basically I saw two possible ways CppInsights might be choosing its output in this case: either it would say "this ctor is noexcept, so I will mark it This example clearly shows what's going on internally: https://cppinsights.io/s/d95de9d0 So at least I see where the noexcept-specifications are coming from now. Seems tricky to fix. |
Fixed #251: Suppress unused compiler generated special members.
Based on the first example from this blog post:
https://cppinsights.io/s/dfd1da7c
produces
This is technically correct, but surprising, because you redundantly place
noexcept
on the default constructor and on the destructor, but you don't redundantly placenoexcept
on the other two special members (even though those members also are implicitly noexcept).And then the
static_assert
s are transformed intoI think this is weird, first because
noexcept(true)
seems less informative than the original code, and second because the "lowered" linewould fail if you put it into a C++ source file. (The expression
false
is in fact non-throwing, sonoexcept(false)
istrue
.) So this particular C++ code is being lowered into not-really-C++ pseudocode. I think this is likely to be more confusing than helpful.The text was updated successfully, but these errors were encountered: