Skip to content

Conversation

joemmett
Copy link
Member

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.

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.
@joemmett joemmett requested a review from a team as a code owner September 18, 2025 13:16
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Sep 18, 2025
@StephanTLavavej StephanTLavavej added the test Related to test code label Sep 18, 2025
@StephanTLavavej
Copy link
Member

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! 😻

@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Sep 18, 2025
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));
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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));.

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Sep 19, 2025
@StephanTLavavej StephanTLavavej changed the title Deduction failures in pointer interconvertibilty trait tests Deduction failures in pointer interconvertibility trait tests Sep 19, 2025
@StephanTLavavej
Copy link
Member

StephanTLavavej commented Sep 19, 2025

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)

@StephanTLavavej StephanTLavavej moved this from Merging to Ready To Merge in STL Code Reviews Sep 19, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Sep 19, 2025
@StephanTLavavej StephanTLavavej merged commit 6d24b53 into microsoft:main Sep 22, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Sep 22, 2025
@StephanTLavavej
Copy link
Member

Thanks for fixing our tests! 😻 🔨 🔧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Related to test code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants