Clang 12 C++20 Modules : declaration of 'basic_string_view' does not match constexpr basic_string_view(const basic_string_view&) noexcept = default;

Viewed 227

I'm using Clang v12.0.0 to build a simple program with a module. Here is the entire program:

// m1.cpp

module;
#include <string>

export module m1;
export auto   f1 () { return std::string ("f1 in module m1"); }
// main.cpp

#include <iostream>
import m1;

int main () { std::cout << "Hello from " << f1 () << "\n"; }

and I'm using these command lines to compile things

D:\Dev\Test\simple>clang++ -std=c++20 -o m1.bmi -c m1.cpp -Xclang -emit-module-interface  
D:\Dev\Test\simple>clang++ -std=c++20 -o main.o -c main.cpp -fmodule-file=m1=m1.bmi

The first command executes without error, and generates the BMI file as expected. But the second command generates a world of errors...

In module 'm1' imported from main.cpp:3:
C:/msys64/ucrt64/include/c++/10.3.0/string_view:142:2: error: 'std::basic_string_view<char>::basic_string_view' from
      module 'm1.<global>' is not present in definition of 'std::basic_string_view<char>' provided earlier
        basic_string_view(_It __first, _End __last)
        ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:120:7: note: declaration of 'basic_string_view' does not match
      basic_string_view() noexcept
      ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:124:17: note: declaration of 'basic_string_view' does not match
      constexpr basic_string_view(const basic_string_view&) noexcept = default;
                ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:127:7: note: declaration of 'basic_string_view' does not match
      basic_string_view(const _CharT* __str) noexcept
      ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:133:7: note: declaration of 'basic_string_view' does not match
      basic_string_view(const _CharT* __str, size_type __len) noexcept
      ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:142:2: note: declaration of 'basic_string_view' does not match
        basic_string_view(_It __first, _End __last)
        ^
In module 'm1' imported from main.cpp:3:
C:/msys64/ucrt64/include/c++/10.3.0/string_view:142:2: error: 'std::basic_string_view::basic_string_view<_CharT,
      _Traits>' from module 'm1.<global>' is not present in definition of 'basic_string_view<_CharT, _Traits>'
      provided earlier
        basic_string_view(_It __first, _End __last)
        ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:120:7: note: declaration of 'basic_string_view<_CharT, _Traits>' does
      not match
      basic_string_view() noexcept
      ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:124:17: note: declaration of 'basic_string_view<_CharT, _Traits>'
      does not match
      constexpr basic_string_view(const basic_string_view&) noexcept = default;
                ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:127:7: note: declaration of 'basic_string_view<_CharT, _Traits>' does
      not match
      basic_string_view(const _CharT* __str) noexcept
      ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:133:7: note: declaration of 'basic_string_view<_CharT, _Traits>' does
      not match
      basic_string_view(const _CharT* __str, size_type __len) noexcept
      ^
C:/msys64/ucrt64/include/c++/10.3.0/string_view:142:2: note: declaration of 'basic_string_view<_CharT, _Traits>' does
      not match
        basic_string_view(_It __first, _End __last)
        ^
2 errors generated.

I'm using MS Code and MSYS2 on Windows 10.

Does anybody have any idea what's going on here?

0 Answers
Related