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

            Bug ID: 99000
           Summary: [modules] declaration std::__copy_move_a2 conflicts
                    with import
           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: ---

The following header unit import causes the "declaration conflicts with import"
error:

cat <<EOF >hello.hxx
#pragma once

#include <string_view>

namespace hello
{
  void
  say_hello (const std::string_view& name);
}
EOF

cat <<EOF >hello.cxx
import "hello.hxx";

#include <iostream>

namespace hello
{
  void
  say_hello (const std::string_view& n)
  {
    std::cout << "Hello, " << n << '!' << std::endl;
  }
}
EOF

g++ -std=c++2a -fmodules-ts -fmodule-header -x c++-header hello.hxx
g++ -std=c++2a -fmodules-ts x c++ -c hello.cxx
In file included from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/bits/locale_facets.h:48,
                 from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/bits/basic_ios.h:37,
                 from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/ios:44,
                 from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/ostream:38,
                 from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/iostream:39,
                 from hello.cxx:3:
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/bits/streambuf_iterator.h:367:72:
error: declaration ‘template<bool _IsMove, class _CharT> typename
__gnu_cxx::__enable_if<std::__is_char<_CharT>::__value, _CharT*>::__type
std::__copy_move_a2(std::istreambuf_iterator<_CharT, std::char_traits<_CharT>
>, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, _CharT*)’
conflicts with import
  367 |                    istreambuf_iterator<_CharT> __last, _CharT*
__result)
      |                                                                       
^
In file included from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/bits/char_traits.h:39,
                 from
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/string_view:41,
                 from hello.hxx:3,
of module ./hello.hxx, imported at hello.cxx:1:
/home/boris/work/build2/tests/modules/gcc2/gcc-install/include/c++/11.0.0/bits/stl_algobase.h:471:5:
note: import declared ‘template<bool _IsMove, class _CharT> typename
__gnu_cxx::__enable_if<std::__is_char<_CharT>::__value, _CharT*>::__type
std::__copy_move_a2(std::istreambuf_iterator<_CharT, std::char_traits<_CharT>
>, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, _CharT*)’ here
  471 |     __copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >,
      |     ^~~~~~~~~~~~~~


Interestingly, if we change the #include and import order in hello.cxx, then
the error goes away.

Reply via email to