Bug 99769 - [modules] internal compiler error: in tree_node, at cp/module.cc:9105 when compile module partitions
Summary: [modules] internal compiler error: in tree_node, at cp/module.cc:9105 when co...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-25 12:11 UTC by owent
Modified: 2021-03-30 01:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-03-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description owent 2021-03-25 12:11:26 UTC
Compiling modules with partitions always failed.The commands and files to reproduce this are below:

$ /opt/gcc-latest/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/opt/gcc-latest/bin/g++
COLLECT_LTO_WRAPPER=/opt/gcc-latest/libexec/gcc/x86_64-pc-linux-gnu/11.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/opt/gcc-latest --enable-languages=c,c++ --enable-libstdcxx-debug --disable-bootstrap --disable-multilib --disable-libvtv --with-system-zlib --without-isl --enable-multiarch
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.1 20210321 (experimental) (GCC)

$ cat foo-types.ixx
module;

export module foo:types;
export class CDerived;

$ cat foo-test.ixx
module;
#include <iostream>
#include <typeinfo>

export module foo:test;
import :types;

export class Bar {
public:
    virtual ~Bar() = default;
    virtual void visit() {
        std::cout << "Bar::visit -> "<< typeid(*this).name() << std::endl;
    }
};

$ cat foo.ixx
module;

export module foo;

export import :types;
export import :test;

$ /opt/gcc-latest/bin/g++ -fmodules-ts -std=c++20 -x c++ -c foo-types.ixx -o foo-types.o
$ /opt/gcc-latest/bin/g++ -fmodules-ts -std=c++20 -x c++ -c foo-test.ixx -o foo-test.o
$ /opt/gcc-latest/bin/g++ -fmodules-ts -std=c++20 -x c++ -c foo.ixx -o foo.o
foo.ixx:3:8: internal compiler error: in tree_node, at cp/module.cc:9105
    3 | export module foo;
      |        ^~~~~~
0x8af602 trees_out::tree_node(tree_node*)
        ../../gcc/cp/module.cc:9105
0x8b0460 trees_out::core_vals(tree_node*)
        ../../gcc/cp/module.cc:5908
0x8b5009 trees_out::tree_node_vals(tree_node*)
        ../../gcc/cp/module.cc:7049
0x8b5009 trees_out::tree_value(tree_node*)
        ../../gcc/cp/module.cc:8936
0x8af522 trees_out::tree_node(tree_node*)
        ../../gcc/cp/module.cc:9134
0x8b0460 trees_out::core_vals(tree_node*)
        ../../gcc/cp/module.cc:5908
0x8b5009 trees_out::tree_node_vals(tree_node*)
        ../../gcc/cp/module.cc:7049
0x8b5009 trees_out::tree_value(tree_node*)
        ../../gcc/cp/module.cc:8936
0x8af522 trees_out::tree_node(tree_node*)
        ../../gcc/cp/module.cc:9134
0x8b0460 trees_out::core_vals(tree_node*)
        ../../gcc/cp/module.cc:5908
0x8b5009 trees_out::tree_node_vals(tree_node*)
        ../../gcc/cp/module.cc:7049
0x8b5009 trees_out::tree_value(tree_node*)
        ../../gcc/cp/module.cc:8936
0x8af522 trees_out::tree_node(tree_node*)
        ../../gcc/cp/module.cc:9134
0x8b0460 trees_out::core_vals(tree_node*)
        ../../gcc/cp/module.cc:5908
0x8b5009 trees_out::tree_node_vals(tree_node*)
        ../../gcc/cp/module.cc:7049
0x8b5009 trees_out::tree_value(tree_node*)
        ../../gcc/cp/module.cc:8936
0x8af522 trees_out::tree_node(tree_node*)
        ../../gcc/cp/module.cc:9134
0x8b0460 trees_out::core_vals(tree_node*)
        ../../gcc/cp/module.cc:5908
0x8b5009 trees_out::tree_node_vals(tree_node*)
        ../../gcc/cp/module.cc:7049
0x8b5009 trees_out::tree_value(tree_node*)
        ../../gcc/cp/module.cc:8936
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Marek Polacek 2021-03-30 01:29:50 UTC
Reproduced.
Comment 2 Marek Polacek 2021-03-30 01:32:26 UTC
We have __dynamic_cast without DECL_CONTEXT and so ICE in

 9050       if (!DECL_CONTEXT (t))
 9051         {
 9052           /* There are a few cases of decls with no context.  We'll write
 9053              these by value, but first assert they are cases we expect.  */
 9054           gcc_checking_assert (ref == WK_normal);
 9055           switch (TREE_CODE (t))
 9056             {
 9057             default: gcc_unreachable ();