[PATCH] D134475: Add C++11 attribute msvc::constexpr

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 05:13:33 PDT 2022


aaron.ballman added a subscriber: cpplearner.
aaron.ballman added a comment.

Pulling a comment out of https://reviews.llvm.org/D133853 that's relevant here:

In D133853#3844851 <https://reviews.llvm.org/D133853#3844851>, @cpplearner wrote:

> In D133853#3808674 <https://reviews.llvm.org/D133853#3808674>, @aaron.ballman wrote:
>
>> Now I'm wondering why the attribute exists at all. If it's functionally equivalent to `constexpr` as a keyword, what are the use cases for the attribute?
>
> It appears that `[[msvc::constexpr]]` does not make a function `constexpr`, but if `[[msvc::constexpr]]` is used in a function definition //and// in a call to that function, then the annotated function call can be evaluated during constant evaluation: https://godbolt.org/z/3MPTsz6Yn
>
> Apparently this is used to implement constexpr `std::construct_at`, which needs to call placement `operator new`, but the latter is not `constexpr`.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134475/new/

https://reviews.llvm.org/D134475



More information about the cfe-commits mailing list