https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119983
Bug ID: 119983 Summary: Member function in unnamed type causes internal compiler error in module. Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: g.mjardev at gmail dot com Target Milestone: --- Created attachment 61228 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61228&action=edit preprocessed source code Inside a C++20 module file, an unnamed struct having a member function will trigger internal compiler error on gcc14.2. ``` $ g++ -v -save-temps -std=c++20 -fmodules-ts bug.cxx Using built-in specs. COLLECT_GCC=C:\msys64\ucrt64\bin\g++.exe COLLECT_LTO_WRAPPER=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-14.2.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,rust,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++ Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 14.2.0 (Rev2, Built by MSYS2 project) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-fmodules-ts' '-shared-libgcc' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/cc1plus.exe -E -quiet -v -iprefix C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/ -D_REENTRANT bug.cxx -mtune=generic -march=nocona -std=c++20 -fmodules-ts -fpch-preprocess -o a-bug.ii ignoring nonexistent directory "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/include" ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include/c++/14.2.0" ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include/c++/14.2.0/x86_64-w64-mingw32" ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include/c++/14.2.0/backward" ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.2.0/include" ignoring nonexistent directory "D:/a/msys64/ucrt64/include" ignoring nonexistent directory "/ucrt64/include" ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.2.0/include-fixed" ignoring nonexistent directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/include" ignoring nonexistent directory "D:/a/msys64/ucrt64/include" #include "..." search starts here: #include <...> search starts here: C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include/c++/14.2.0 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include/c++/14.2.0/x86_64-w64-mingw32 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include/c++/14.2.0/backward C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/include C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../include C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/include-fixed End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-fmodules-ts' '-shared-libgcc' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/cc1plus.exe -fpreprocessed a-bug.ii -quiet -dumpdir a- -dumpbase bug.cxx -dumpbase-ext .cxx -mtune=generic -march=nocona -std=c++20 -version -fmodules-ts -o a-bug.s GNU C++20 (Rev2, Built by MSYS2 project) version 14.2.0 (x86_64-w64-mingw32) compiled by GNU C version 14.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.27-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 0ae76c501e8dc149b84d2c95ded0e2f3 bug.cxx:4:10: internal compiler error: in write_unnamed_type_name, at cp/mangle.cc:1806 4 | void aRandomFunc() | ^~~~~~~~~~~ Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://github.com/msys2/MINGW-packages/issues> for instructions. ``` While I'm using mingw w64 ucrt version of gcc, this behavior is reproduceable https://godbolt.org/z/5oPv5bTW7 . Code compiles with gcc 13 and generates a compiler error for gcc 15: https://godbolt.org/z/zfeefofvG . Code works with clang 19, haven't tested other versions of clang. Adding a name to the type fixes error with all versions. Disabling modules and removing all module related things also fixes the error. The variable declaration isn't required, error can be triggered with a standalone nameless struct. In my limited understanding of C++, code is well-formed.