public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99050] New: [modules] ICE in cpp_directive_only_process on include translation
@ 2021-02-10  5:20 boris at kolpackov dot net
  2021-02-16 20:27 ` [Bug c++/99050] " nathan at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: boris at kolpackov dot net @ 2021-02-10  5:20 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/99050] [modules] ICE in cpp_directive_only_process on include translation
  2021-02-10  5:20 [Bug c++/99050] New: [modules] ICE in cpp_directive_only_process on include translation boris at kolpackov dot net
@ 2021-02-16 20:27 ` nathan at gcc dot gnu.org
  2021-02-17  6:29 ` boris at kolpackov dot net
  2021-02-17  9:21 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-16 20:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99050

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Fixed b37695c9bf1 2021-02-16 | c++: directives-only preprocessing and include
translation [PR 99050]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/99050] [modules] ICE in cpp_directive_only_process on include translation
  2021-02-10  5:20 [Bug c++/99050] New: [modules] ICE in cpp_directive_only_process on include translation boris at kolpackov dot net
  2021-02-16 20:27 ` [Bug c++/99050] " nathan at gcc dot gnu.org
@ 2021-02-17  6:29 ` boris at kolpackov dot net
  2021-02-17  9:21 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: boris at kolpackov dot net @ 2021-02-17  6:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99050

--- Comment #2 from Boris Kolpackov <boris at kolpackov dot net> ---
Can confirm now works for me, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/99050] [modules] ICE in cpp_directive_only_process on include translation
  2021-02-10  5:20 [Bug c++/99050] New: [modules] ICE in cpp_directive_only_process on include translation boris at kolpackov dot net
  2021-02-16 20:27 ` [Bug c++/99050] " nathan at gcc dot gnu.org
  2021-02-17  6:29 ` boris at kolpackov dot net
@ 2021-02-17  9:21 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-17  9:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99050

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
https://gcc.gnu.org/g:b37695c9bf101a3a30a231cfeb6da7a6c17657d6

commit r11-7260-gb37695c9bf101a3a30a231cfeb6da7a6c17657d6
Author: Nathan Sidwell <nathan@acm.org>
Date:   Tue Feb 16 12:23:12 2021 -0800

    c++: directives-only preprocessing and include translation [PR 99050]

    We make sure files end in \n by placing one at the limit of the buffer
    (just past the end of what is read).  We need to do the same for
    buffers generated via include-translation.  Fortunately they have
    space.

            libcpp/
            * files.c (_cpp_stack_file): Make buffers end in unread \n.
            gcc/testsuite/
            * g++.dg/modules/pr99050_a.H: New.
            * g++.dg/modules/pr99050_b.C: New.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-17  9:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10  5:20 [Bug c++/99050] New: [modules] ICE in cpp_directive_only_process on include translation boris at kolpackov dot net
2021-02-16 20:27 ` [Bug c++/99050] " nathan at gcc dot gnu.org
2021-02-17  6:29 ` boris at kolpackov dot net
2021-02-17  9:21 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).