STL
STL copied to clipboard
`<regex>`: Constants in `std::regex_constants` are not `constexpr` variables
Describe the bug
The Standard specified that constants in std::regex_constants to be constexpr variables ([re.const]).
However, MSVC STL just implements them as enumerators of unscoped enumerations, which are not variables.
It seems that they have never been specified be to non-object. In TR1 (WG21-N1836) they were static const variables.
Command-line test case
Additional context
libc++ is similarly buggy (llvm/llvm-project#69420).
Also tracked by VSO-498998 / AB#498998 .
Did you have an actual problem with a program you wrote, or is this just a paper bug report? I think it's better that these constants are prvalues - they don't waste space in object files. We should consider submitting an LWG issue to allow our implementation. (I suspect C++11 used constexpr variables out of an abundance of enthusiasm for the new feature, and not for any technical reason.)
I think it's better that these constants are prvalues - they don't waste space in object files.
Oh, WG21-P0439R0 may be related - it changed previous enumerators to constexpr variables. But in C++20 there's using enum, so it's possible to keep the constants in std being prvalues while making std::memory_order scoped.
We talked about this at the weekly maintainer meeting and we're basically in agreement that this is legitimately a conformance issue, albeit one of extremely limited importance, and we would accept a PR to resolve this.
LWG-3998 is opened for this. Perhaps we can add "decision needed" back?