-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Deduction failures in pointer interconvertibility trait tests #5730
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
Deduction failures in pointer interconvertibility trait tests #5730
Conversation
An upcoming MSVC version will fix a bug that caused us to accept some template argument deduction cases that should be deduction failures. Specifically, with a template parameter `R (C::*)` where `C` was explicity specified you can't deduce `R` from a pointer-to-member with a mismatched class type, even one that has an implicit conversion. The pointer interconvertibility trait tests included a few of these situations where a template argument was explicitly specified but a pointer-to-member of a base class type was provided.
Mirror of MSVC-PR-671469, @joemmett's compiler fix for DevCom-10963535 VSO-2573454 "[accepts invalid] Pointer-to-member of base class as template argument". Thanks! 😻 |
ASSERT(!is_corresponding_member(&S5::v1, &S6::v2)); | ||
ASSERT(!is_corresponding_member(&S5::v2, &S6::v1)); | ||
ASSERT(!is_corresponding_member(&S5::v3, &S6::v3)); | ||
ASSERT(!is_corresponding_member<NS, NS>(&NS::v1, &NS::w1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion is directly translated from the example in the standard's [meta.member]. We might need to tell the committee that this example is problematic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example does note that it fails, but not why it fails:
static_assert( is_corresponding_member<C, C>( &C::a, &C::b ) );
// Forces the use of class C, and fails.
It's reasonable to assume that this would fail the static_assert, but it actually fails deduction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's better to use is_corresponding_member<C, C, int, int>( &C::a, &C::b )
to achieve implicit conversion. Correspondingly, it's perhaps better to modify the line in the test file to ASSERT(!is_corresponding_member<NS, NS, int, int>(&NS::v1, &NS::w1));
.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. (I forgot that this was being mirrored as part of the compiler fix but after checking with Jonathan I'll go ahead and mirror this as it can go in independently) |
Thanks for fixing our tests! 😻 🔨 🔧 |
An upcoming MSVC version will fix a bug that caused us to accept some template argument deduction cases that should be deduction failures. Specifically, with a template parameter
R (C::*)
whereC
was explicity specified you can't deduceR
from a pointer-to-member with a mismatched class type, even one that has an implicit conversion.The pointer interconvertibility trait tests included a few of these situations where a template argument was explicitly specified but a pointer-to-member of a base class type was provided.