https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112624
Bug ID: 112624 Summary: Internal compiler error when compiling a module Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: amaikinono at gmail dot com Target Milestone: --- Created attachment 56644 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56644&action=edit Preprocessed file. Sorry for the vague title as I am still new to C++ and don't have better understanding of the bug. Here are the source files: ``` // mod.cxx module; #include <string> export module mod; export class Example { public: const std::string& display() const; }; ``` ``` // mod_impl.cpp #include <format> #include <string> const std::string& display() { return std::format("hi {}", 1); } ``` Compile it: ``` $ g++ -std=c++20 -fmodules-ts -c mod.cxx [kino@kino-pc /yard/new-box/works/code-snippets/2023-professional-cpp/gcc-bug] $ g++ -std=c++20 -fmodules-ts -c mod.o mod_impl.cpp mod_impl.cpp: In function ‘const std::string& display()’: mod_impl.cpp:6:21: warning: returning reference to temporary []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wreturn-local-addr-Wreturn-local-addr]8;;] 6 | return std::format("hi {}", 1); | ~~~~~~~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/13.2.1/bits/locale_classes.h:869, from /usr/include/c++/13.2.1/locale:41, from /usr/include/c++/13.2.1/format:42, of module /usr/include/c++/13.2.1/format, imported at mod_impl.cpp:1: /usr/include/c++/13.2.1/bits/locale_classes.tcc: In instantiation of ‘const _Facet& std::use_face (const locale&) [with _Facet = ctype<wchar_t>]’: /usr/include/c++/13.2.1/format:2135:45: required from ‘typename std::basic_format_context<_Out, _CharT>::iterator std::formatter<const void*, _CharT>::format(const void*, std::basic_format_context<_Out, _CharT>&) const [with _Out = std::__format::_Sink_iter<wchar_t>; _CharT = wchar_t; typename std::basic_format_context<_Out, _CharT>::iterator = std::basic_format_context<std::__format::_Sink_iter<wchar_t>, wchar_t>::iterator]’ /usr/include/c++/13.2.1/format:3581:41: required from ‘std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>, wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:31&)> [with auto:31 = const void*]’ /usr/include/c++/13.2.1/format:3084:44: required from ‘decltype(auto) std::basic_format_arg<_Context>::_M_visit(_Visitor&&, std::__format::_Arg_t) [with _Visitor = std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>, wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:31&)>; _Context = std::basic_format_context<std::__format::_Sink_iter<wchar_t>, wchar_t>]’ /usr/include/c++/13.2.1/format:3111:28: required from ‘decltype(auto) std::visit_format_arg(_Visitor&&, basic_format_arg<_Context>) [with _Visitor = __format::_Formatting_scanner<__format::_Sink_iter<wchar_t>, wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:31&)>; _Context = basic_format_context<__format::_Sink_iter<wchar_t>, wchar_t>]’ /usr/include/c++/13.2.1/format:3570:23: required from ‘constexpr void std::__format::_Formatting_scanner<_Out, _CharT>::_M_format_arg(std::size_t) [with _Out = std::__format::_Sink_iter<wchar_t>; _CharT = wchar_t; std::size_t = long unsigned int]’ /usr/include/c++/13.2.1/format:3565:7: required from here /usr/include/c++/13.2.1/bits/locale_classes.tcc:200:60: internal compiler error: in tsubst_copy, at cp/pt.cc:17292 200 | if (const _Facet* __f = std::__try_use_facet<_Facet>(__loc)) | ^~~~~ 0x1ad33c8 internal_error(char const*, ...) ???:0 0x6b7b63 fancy_abort(char const*, int, char const*) ???:0 0x85da9c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*) ???:0 0x85df90 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*) ???:0 0x85e183 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*) ???:0 0x85663d instantiate_decl(tree_node*, bool, bool) ???:0 0x87ad63 instantiate_pending_templates(int) ???:0 0x7714d6 c_parse_final_cleanups() ???:0 0x9444b4 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://bugs.archlinux.org/> for instructions. ``` Outputs of `gcc -v`: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20230801 (GCC)