Skip to content

libc++ disagrees with libstd++ on constexpr std::string construction legality #68434

Closed
@pkasting

Description

@pkasting

The following code compiles with libstd++, but not libc++:

#include <iostream>
#include <string>

struct S {
  std::string s_;
};

constexpr S s{"Test"};

int main() {
  std::cout << s.s_;
  return 0;
}

Online repro: https://godbolt.org/z/fjdnrPceh

It seems like either this is legal or it isn't. I'm not well-versed in the minutiae of constexpr std::strings in C++20, but my layman's impression is that this ought to work, so libstdc++ is correct and libc++ is wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions