https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98843
Bug ID: 98843 Summary: Building simple c++ modules example fails but successful with -save-temps Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at boltav dot me.uk Target Milestone: --- Checked out and built: g++ (GCC) 11.0.0 20210125 (experimental) @ commit a61efd469371b71483d42afa1038e6a8c16baf4a (HEAD -> master, origin/master, origin/HEAD) When I try to build the sources below, the build fails. However when I added -save-temps for this bug report the build succeeded! sources below from https://vector-of-bool.github.io/2019/03/10/modules-1.html source - mod.cpp export module speech; export const char* get_phrase() { return "Hello, world!"; } source - main.cpp // main.cpp import speech; import <iostream>; int main() { std::cout << get_phrase() << '\n'; } Commands for build: g++ --version g++ -c -std=c++20 -fmodules-ts -o mod.o ../src/mod.cpp g++ -std=c++20 -fmodules-ts -x c++-system-header iostream g++ -c -std=c++20 -fmodules-ts -o main.o ../src/main.cpp Diagnostic: g++ (GCC) 11.0.0 20210125 (experimental) Copyright © 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ‘ In file included from /home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/bits/ios_base.h:46, from /home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/ios:42, from /home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/ostream:38, from /home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/iostream:39, of module /home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/iostream, imported at /home/gary/Projects/module-test/builds/../src/main.cpp:4: in import_entity_module, at cp/module.cc:4083 189 | template<typename _ErrorCodeEnum, typename = typename | ^~~~~~~~ 0x82e83c import_entity_module /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:4083 0x841640 get_importing_module(tree_node*, bool) /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:18348 0x7d0026 dump_module_suffix /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:205 0x7d0f1a dump_module_suffix /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:187 0x7d0f1a dump_aggr_type /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:806 0x7dc609 dump_function_decl /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:1717 0x7df417 subst_to_string /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3384 0x7df417 cp_printer /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:4376 0x1d000f1 pp_format(pretty_printer*, text_info*) /home/gary/Repo/GitRepo/g++with-mod/gcc/pretty-print.c:1475 0x1d00770 pp_format_verbatim(pretty_printer*, text_info*) /home/gary/Repo/GitRepo/g++with-mod/gcc/pretty-print.c:1536 0x1d00851 pp_verbatim(pretty_printer*, char const*, ...) /home/gary/Repo/GitRepo/g++with-mod/gcc/pretty-print.c:1790 0x7cfd0f print_instantiation_full_context /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3589 0x7e0652 maybe_print_instantiation_context /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3737 0x7e0652 cp_diagnostic_starter /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3428 0x1ce2de6 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1245 0x1ce340e diagnostic_impl /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1406 0x1ce4259 internal_error(char const*, ...) /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1808 0x6b6a8b fancy_abort(char const*, int, char const*) /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1907 0x82e83c import_entity_module /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:4083 0x865df2 pendset_lazy_load /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:13669 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Build dir layout after (because modules): $ tree . ├── gcm.cache │ ├── home │ │ └── gary │ │ └── Projects │ │ └── g++mod │ │ └── install │ │ └── 20210125 │ │ └── include │ │ └── c++ │ │ └── 11.0.0 │ │ └── iostream.gcm │ └── speech.gcm ├── mod.o └── mods.sh System: Linux 5.4.0-64-generic #72~18.04.1-Ubuntu SMP Fri Jan 15 14:06:34 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Version and options: → g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)