Skip to content

<memory>: Make algorithms properly destroy objects in constant evaluation #5449

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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
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
Status: Ready To Merge
Development

Successfully merging this pull request may close these issues.

3 participants