https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

            Bug ID: 99377
           Summary: [modules] undefined std::string_view::empty() if
                    referenced in inline exported function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris at kolpackov dot net
  Target Milestone: ---

cat <<EOF >hello.mxx
export module hello;

import <string_view>;

export namespace hello
{
  inline bool check (const std::string_view& n)
  {
    return !n.empty ();
  }
}
EOF

cat <<EOF >main.cxx
import hello;

int main ()
{
  return hello::check ("World") ? 0 : 1;
}
EOF

g++ -std=c++2a -fmodules-ts -fmodule-header -x c++-header
.../include/c++/11.0.1/string_view
g++ -std=c++2a -fmodules-ts -c -x c++ hello.mxx
g++ -std=c++2a -fmodules-ts -c -x c++ main.cxx 
g++ -std=c++2a -fmodules-ts hello.o main.o 

main.o: In function `hello::check(std::basic_string_view<char,
std::char_traits<char> > const&)':
main.cxx:(.text._ZN5hello5checkERKSt17basic_string_viewIcSt11char_traitsIcEE[_ZN5hello5checkERKSt17basic_string_viewIcSt11char_traitsIcEE]+0x14):
undefined reference to `std::basic_string_view<char, std::char_traits<char>
>::empty() const'

The error goes away if hello::check is made non-inline.

Reply via email to