https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114867
Bug ID: 114867 Summary: [modules] name lookup issues when a function overload set is exported from GMF Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m.cencora at gmail dot com Target Milestone: --- $ cat future.cpp module; namespace std { template<class _Tp> void swap(_Tp& a, _Tp& b); namespace __exception_ptr { class exception_ptr {}; void swap(exception_ptr&, exception_ptr&); } using __exception_ptr::swap; template < typename _Tp> struct shared_ptr { void swap(shared_ptr& other) { std::swap(_M_ptr, other._M_ptr); } _Tp *_M_ptr; }; struct future { shared_ptr< void > _M_state; void operator=(future& other) { _M_state.swap(other._M_state); } }; } // std export module std; namespace std { using std::swap; } $ g++ -std=c++2b -fmodules-ts -Wno-global-module future.cpp <source>: In instantiation of 'void std::shared_ptr<_Tp>::swap(std::shared_ptr<_Tp>&) [with _Tp = void]': <source>:23:48: required from here 23 | void operator=(future& other) { _M_state.swap(other._M_state); } | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ <source>:17:44: error: invalid initialization of reference of type 'std::__exception_ptr::exception_ptr&' from expression of type 'void*' 17 | void swap(shared_ptr& other) { std::swap(_M_ptr, other._M_ptr); } | ^~~~~~ <source>:10:11: note: in passing argument 1 of 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 10 | void swap(exception_ptr&, exception_ptr&); | ^~~~~~~~~~~~~~ <source>:27:8: warning: not writing module 'std' due to errors 27 | export module std; | ^~~~~~ This is reduced code from an issue found when creating std module(https://gcc.gnu.org/PR114600#c10) module; #include <future> export module std; export namespace std { using std::swap; } The problem seems to be that using __exception_ptr::swap; hides any other previous declaration of swap function. The workarounds is to move decl of template swap after the using __exception_ptr::swap; Also this compiles fine if we change shared_ptr::_M_ptr to not become a template dependent type.