Skip to content

<memory>: Fix constraints of shared_ptr's constructors when the involved pointer type would be invalid#4290

Merged
StephanTLavavej merged 3 commits intomicrosoft:mainfrom
frederick-vs-ja:shared_ptr-constraints
Jan 11, 2024
Merged

<memory>: Fix constraints of shared_ptr's constructors when the involved pointer type would be invalid#4290
StephanTLavavej merged 3 commits intomicrosoft:mainfrom
frederick-vs-ja:shared_ptr-constraints

Conversation

@frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Dec 25, 2023

There are weird things in [util.smartptr.shared.const]/3 and [util.smartptr.shared.const]/9.1: Y(*)[N] or Y(*)[] is not necessary a valid type, e.g. when Y is T[] or a function type, which means that the constraints themselves can be sometimes ill-formed.

Presumably there should be substitution failures in such cases (instead of hard errors or UB/IFNDR). I've tried to submit an LWG issue for this.

void_t<decltype(static_cast<_Yty (*)[]>(nullptr))> works while void_t<_Yty (*)[]> doesn't for MSVC. Reported DevCom-10548086.

Unblocks 2 libcxx tests:

  • std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
  • std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner December 25, 2023 17:37
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Jan 10, 2024
@StephanTLavavej StephanTLavavej self-assigned this Jan 10, 2024
@StephanTLavavej StephanTLavavej removed their assignment Jan 11, 2024
@StephanTLavavej
Copy link
Member

I pushed a merge with main to resolve a trivial adjacent-delete conflict in tests/libcxx/expected_results.txt.

Thanks for investigating and fixing this failure! 😻 I noticed that the DevCom bug you reported was near-immediately fixed, so I appropriately tagged it internally as fixed in VS 2022 17.10 Preview 1, and added it to my notes for when I perform the 17.10p1 toolset update.

@StephanTLavavej StephanTLavavej self-assigned this Jan 11, 2024
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 77036d6 into microsoft:main Jan 11, 2024
@frederick-vs-ja frederick-vs-ja deleted the shared_ptr-constraints branch January 11, 2024 23:32
@StephanTLavavej
Copy link
Member

Thanks for fixing these libcxx failures and making our smart pointers even smarter! 🧠 📈 😹

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

Labels

enhancement Something can be improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants