Skip to content

Failure to compile std::u16string from libstdc++ 12.1 in c++20 mode #55560

Closed
@patstew

Description

@patstew

I'm getting:

error: undefined symbol: void std::__cxx11::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t> >::_M_construct<char16_t const*>(char16_t const*, char16_t const*, std::forward_iterator_tag)

compiling the following simple test case:

#include <string>
#include <string_view>

// static std::u16string clang_string_workaround(const char16_t* a, const char16_t* b) { return {a, b}; }

std::u16string_view sv{u"test"};

std::u16string print() { return std::u16string(sv); }

int main(int, char**) { std::u16string s = print(); }

on clang 13 and 14.0.0, with clang++ -std=c++20 -o test test.cpp. It works fine with -std=c++17. Bizarrely, it also works if you simply uncomment the clang_string_workaround line which isn't even called. It looks like libstdc++ moved that _M_construct function into a separate file recently, which might be related.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions