KEMBAR78
`<memory>`: Make algorithms properly destroy objects in constant evaluation by frederick-vs-ja · Pull Request #5449 · microsoft/STL · GitHub
Skip to content

Conversation

@frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Apr 29, 2025

Currently, MSVC STL's destroying algorithms skip ranges whose element types are trivially destructible. This is slightly non-conforming, because further access to the destroyed objects should cause core language UB and in turn cause constant evaluation failure.

This PR makes std::(ranges::)destroy(_at, _n) always destroy objects during constant evaluation. The behavior difference is currently only observable by Clang due to bugs of MSVC (DevCom-10642767) and EDG (DevCom-10896316).

The allocator-aware _Destroy_range is not yet touched, because any attempt to access an element destroyed by that overload will raise library UB first.

Related to #5225, although the "vectorized implementation" is no-op in these algorithms. The change about if consteval are dropped. See the review comments.

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Apr 29, 2025
@StephanTLavavej StephanTLavavej self-assigned this Apr 29, 2025
@github-project-automation github-project-automation bot moved this from Initial Review to Work In Progress in STL Code Reviews May 2, 2025
@StephanTLavavej StephanTLavavej removed their assignment May 2, 2025
@StephanTLavavej StephanTLavavej self-assigned this May 3, 2025
@StephanTLavavej StephanTLavavej moved this from Work In Progress to Initial Review in STL Code Reviews May 3, 2025
@StephanTLavavej StephanTLavavej removed their assignment May 3, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews May 3, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews May 9, 2025
@StephanTLavavej
Copy link
Member

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

StephanTLavavej added a commit to StephanTLavavej/STL that referenced this pull request May 9, 2025
@StephanTLavavej StephanTLavavej merged commit 53463dd into microsoft:main May 10, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews May 10, 2025
@StephanTLavavej
Copy link
Member

ALL WILL BE DESTROYED!!! 🦹 💣 💥

@frederick-vs-ja frederick-vs-ja deleted the real-constexpr-destroy branch May 10, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants