https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116807
Bug ID: 116807 Summary: About c++ 20 module,chrono header file Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wxy_it at 163 dot com Target Milestone: --- Created attachment 59173 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59173&action=edit the code for reproduction When both module A and module B include the <chrono> header in the global module, and module A imports module B, it will cause a bug. I tried modifying the "auto" at line 2631 of /usr/local/include/c++/14.2.0/format to the actual type "_Sink<_CharT>::_Reservation", which can fix the bug. The attached file contains the code for reproduction. I used CMake for the build, and the runtime environment is the gcc:14.2.0-bookworm Docker image, with the image ID 5b2fe0643fc9. [main] Building folder: /root/workspace/module_test/build [build] Starting build [proc] Executing command: /root/cmake-3.30.3-linux-x86_64/bin/cmake --build /root/workspace/module_test/build --config Debug --target all -- [build] [1/7 14% :: 0.039] Scanning /root/workspace/module_test/a.cpp for CXX dependencies [build] [2/7 28% :: 0.041] Generating CXX dyndep file CMakeFiles/demo.dir/CXX.dd [build] [3/4 75% :: 0.347] Building CXX object CMakeFiles/demo.dir/a.cpp.o [build] FAILED: CMakeFiles/demo.dir/a.cpp.o [build] /usr/local/bin/g++ -g -std=gnu++20 -MD -MT CMakeFiles/demo.dir/a.cpp.o -MF CMakeFiles/demo.dir/a.cpp.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/demo.dir/a.cpp.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/demo.dir/a.cpp.o -c /root/workspace/module_test/a.cpp [build] In file included from /usr/local/include/c++/14.2.0/bits/chrono_io.h:39, [build] from /usr/local/include/c++/14.2.0/chrono:3360, [build] from /root/workspace/module_test/a.ixx:3, [build] of module ModuleA, imported at /root/workspace/module_test/a.cpp:6: [build] /usr/local/include/c++/14.2.0/bits/basic_string.tcc: In substitution of 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&) [with _Tp = std::__cxx11::to_string(int)::<lambda(char*, std::size_t)>&]': [build] /usr/local/include/c++/14.2.0/bits/basic_string.tcc:602:27: required from 'constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__resize_and_overwrite(size_type, _Operation) [with _Operation = std::__cxx11::to_string(int)::<lambda(char*, std::size_t)>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' [build] 602 | auto __r = std::move(__op)(__p + 0, __n + 0); [build] | ~~~~~~~~~^~~~~~ [build] /usr/local/include/c++/14.2.0/bits/basic_string.h:4249:33: required from here [build] 4249 | __str.__resize_and_overwrite(__neg + __len, [=](char* __p, size_t __n) { [build] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [build] 4250 | __p[0] = '-'; [build] | ~~~~~~~~~~~~~ [build] 4251 | __detail::__to_chars_10_impl(__p + (int)__neg, __len, __uval); [build] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [build] 4252 | return __n; [build] | ~~~~~~~~~~~ [build] 4253 | }); [build] | ~~ [build] /usr/local/include/c++/14.2.0/format:2632:7: error: conflicting global module declaration 'auto std::__format::_Sink_iter@ModuleB<_CharT>::_M_reserve(std::size_t) const [with _CharT = char; std::size_t = long unsigned int]' [build] 2632 | _M_reserve(size_t __n) const [build] | ^~~~~~~~~~ [build] In file included from /usr/local/include/c++/14.2.0/bits/chrono_io.h:39, [build] from /usr/local/include/c++/14.2.0/chrono:3360, [build] from /root/workspace/module_test/b.ixx:3, [build] of module ModuleB, imported at /root/workspace/module_test/a.ixx:6, [build] of module ModuleA, imported at /root/workspace/module_test/a.cpp:6: [build] /usr/local/include/c++/14.2.0/format:2632:7: note: existing declaration 'auto std::__format::_Sink_iter@ModuleB<_CharT>::_M_reserve(std::size_t) const [with _CharT = char; std::size_t = long unsigned int]' [build] 2632 | _M_reserve(size_t __n) const [build] | ^~~~~~~~~~ [build] In file included from /usr/local/include/c++/14.2.0/string:55, [build] from /usr/local/include/c++/14.2.0/bits/locale_classes.h:40, [build] from /usr/local/include/c++/14.2.0/bits/ios_base.h:41, [build] from /usr/local/include/c++/14.2.0/ios:44, [build] from /usr/local/include/c++/14.2.0/ostream:40, [build] from /usr/local/include/c++/14.2.0/iostream:41, [build] from /root/workspace/module_test/a.cpp:3: [build] /usr/local/include/c++/14.2.0/bits/basic_string.tcc:602:27: note: during load of pendings for 'std::move' [build] 602 | auto __r = std::move(__op)(__p + 0, __n + 0); [build] | ~~~~~~~~~^~~~~~ [build] ninja: build stopped: subcommand failed. [proc] The command: /root/cmake-3.30.3-linux-x86_64/bin/cmake --build /root/workspace/module_test/build --config Debug --target all -- exited with code: 1