https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99050
Bug ID: 99050
Summary: [modules] ICE in cpp_directive_only_process on include
translation
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: boris at kolpackov dot net
Target Milestone: ---
After the fix in bug 98882 I now get an ICE (that same assert) when partially
preprocessing (-E -fdirectives-only) a TU that has an include directive that is
translated to an import:
cat <<EOF >hello.hxx
void f ();
EOF
cat <<EOF >main.cxx
#include "hello.hxx"
//import "hello.hxx";
int main () {}
EOF
cat <<EOF >mapper
#!/usr/bin/env bash
function info () { echo "$*" 1>&2; }
function resp () { info " < $*"; echo "$*"; }
while read l; do
info " > $l"
case "$l" in
HELLO*)
resp "HELLO 1 test ;"
;;
MODULE-REPO)
resp "PATHNAME /"
;;
INCLUDE-TRANSLATE*hello.hxx)
resp "PATHNAME $(pwd)/hello.gcm"
;;
INCLUDE-TRANSLATE*)
resp "BOOL FALSE"
;;
MODULE-EXPORT*|MODULE-IMPORT*)
resp "PATHNAME $(pwd)/hello.gcm"
;;
MODULE-COMPILED*)
resp "OK"
;;
*)
resp "ERROR 'unexpected request: $l'"
;;
esac
done
EOF
chmod ugo+x ./mapper
g++ -std=c++2a -fmodules-ts -fmodule-mapper='|./mapper' -fmodule-header -x c++
header hello.hxx
g++ -std=c++2a -fmodules-ts -fmodule-mapper='|./mapper' -E -fdirectives-only -x
c++ -o main.ii main.cxx
main.cxx:1: internal compiler error: in cpp_directive_only_process, at
libcpp/lex.c:4323
0x2c26a7a cpp_directive_only_process(cpp_reader*, void*, void (*)(cpp_reader*,
CPP_DO_task, void*, ...))
../../gcc/libcpp/lex.c:4323
0xf1745e scan_translation_unit_directives_only
../../gcc/gcc/c-family/c-ppoutput.c:402
0xf16928 preprocess_file(cpp_reader*)
../../gcc/gcc/c-family/c-ppoutput.c:100
0xf10e2b c_common_init()
../../gcc/gcc/c-family/c-opts.c:1195
0xbe8ea7 cxx_init()
../../gcc/gcc/cp/lex.c:332
0x180c1af lang_dependent_init
../../gcc/gcc/toplev.c:1881
0x180ca61 do_compile
../../gcc/gcc/toplev.c:2178
Note that there is no assert if we are using import directly, without include
translation.