Skip to content

<regex>: Constants in std​::​regex_constants are not constexpr variables #4100

Description

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

Godbolt link

Additional context

libc++ is similarly buggy (llvm/llvm-project#69420).

Also tracked by VSO-498998 / AB#498998 .

Activity

  1. CaseyCarter commented on Oct 18, 2023

    @CaseyCarter
    Contributor

    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.)

  2. frederick-vs-ja commented on Oct 18, 2023

    @frederick-vs-ja
    ContributorAuthor

    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.

  3. StephanTLavavej commented on Oct 18, 2023

    @StephanTLavavej
    Member

    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.

  4. frederick-vs-ja commented on Oct 21, 2023

    @frederick-vs-ja
    ContributorAuthor

    LWG-3998 is opened for this. Perhaps we can add "decision needed" back?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregexmeow is a substring of homeowner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions