https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98944
Steven Sun <StevenSun2021 at hotmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |StevenSun2021 at hotmail dot com --- Comment #1 from Steven Sun <StevenSun2021 at hotmail dot com> --- I met the same problem. ------------------------------------------------------------------------- Three days ago, I pull from the repository and then compile the gnu c++ compiler in the devel/c++-modules branch. system: ubuntu-20.04 x86_64 configured with: --disable-multilib I took the same exaple as you, which is in the final working draft n4861 [modules.unit]. I think the compile order should be tu3 tu2 tu1 tu4, because the compiler tells me I cannot import before build. So I compile it as g++ -fmodules-ts -std=c++20 -c 3.cc -o 3.o g++ -fmodules-ts -std=c++20 -c 2.cc -o 2.o g++ -fmodules-ts -std=c++20 -c 1.cc -o 1.o g++ -fmodules-ts -std=c++20 -c 4.cc -o 4.o The compiling for 4.cc got an error ------------------------------------------------------ In module imported at 4.cc:1:1: A: error: failed to read compiled module: Bad file data A: note: compiled module file is ‘gcm.cache/A.gcm’ A: fatal error: returning to the gate for a mechanical issue compilation terminated. ------------------------------------------------------ Then I took a peek into the gcm.cache/A.gcm, using readelf. Found that there's already a section header named bar. So I removed the line `import :Internals;` in 4.cc and it compiles. Anyway, I don't know if that is a bug. Maybe the standard is different from the final working draft. I am not sure.