Skip to content

Implement LWG-3436 std::construct_at should support arrays - #5920

Merged
Stephan T. Lavavej (StephanTLavavej) merged 12 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-3436
Feb 2, 2026
Merged

Implement LWG-3436 std::construct_at should support arrays#5920
Stephan T. Lavavej (StephanTLavavej) merged 12 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-3436

Conversation

@frederick-vs-ja

@frederick-vs-ja A. Jiang (frederick-vs-ja) commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Fixes #5110.

Currently, all tested compilers (MSVC, Clang, and EDG) need some workaround for constant evaluation.

  • MSVC is blocked by lack of [[msvc::constexpr]] of the involved operator new[] in VCRuntime.
    • I'm attempting to introduce a new operator new[] overload, which is sufficiently constrained to avoid affecting overload resolution, as a workaround. However, it doesn't work for non-trivially destructible element types, because MSVC will require additional space to record the number of class objects to destroy.
  • Clang crashes when directly using the final resolution of LWG-3436.
    • The old proposed resolution is used as a workaround.
  • EDG simply can't accept the final resolution in constant evaluation.
    • The old proposed resolution is used as a workaround.
  • Also, EDG doesn't correctly recognize the allocated element type of std::allocator<T[N]>::allocate in constant evaluation.
    • Workaround is unknown, so such case isn't made supported for EDG yet.
  • Also, EDG crashes in some cases in constant evaluation.
    • Workaround is unknown, so such case isn't made supported for EDG yet.

Reported issues:

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the LWG Library Working Group issue label Dec 1, 2025
Comment thread stl/inc/xutility Outdated
Comment thread tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp Outdated
Comment thread tests/std/tests/P1004R2_constexpr_vector/test.cpp Outdated
Comment thread tests/std/tests/P1004R2_constexpr_vector/test.cpp Outdated
Comment thread tests/std/tests/P1004R2_constexpr_vector/test.cpp Outdated
Comment thread tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp Outdated
Comment thread tests/std/tests/P0784R7_library_support_for_more_constexpr_containers/test.cpp Outdated
Comment thread tests/std/tests/P1004R2_constexpr_vector/test.cpp Outdated
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for reporting all of these compiler bugs, I really appreciate it! 😻

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Ready To Merge in STL Code Reviews Jan 30, 2026
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Jan 30, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

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

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 7f083b9 into microsoft:main Feb 2, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Feb 2, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

⚙️ 😻 🎁

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

Labels

LWG Library Working Group issue

2 participants