[Bug c++/114990] Compiler errors in <type_traits> compiling a module-based app
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed May 8 19:00:42 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114990
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Depends on| |99000
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
After preprocessing, it seems Main.cpp basically boils down to:
import CompilerVersions; // #1
#include <type_traits> // #2
import TypeTraits; // #3
int main()
{
return 0;
}
The issue here seems to be the #include <type_traits> appearing after the
import of CompilerVersions which (indirectly) also includes <type_traits> (in
its GMF). GCC currently supports import-after-include GMF merging (so #2
followed by #3 is OK) not but include-after-import. See also
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Modules.html
So one workaround would be to arrange that all #includes come before imports
which might include the same thing. Another workaround would be to compile the
problematic headers (<type_traits> in this case) as a header unit so that
#includes thereof implicitly translated into imports, via e.g.
g++ -fmodules-ts -x c++-system-header type_traits
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99000
[Bug 99000] [modules] merging of textual redefinitions: declaration
std::__copy_move_a2 conflicts with import
More information about the Gcc-bugs
mailing list