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

            Bug ID: 120412
           Summary: Modules ICE using decltype and lambda across TUs
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cjangus at gmail dot com
  Target Milestone: ---

This may be doing something ill-advised, I believe there are some potential
issues with lambda type linkage, but anyway it obviously shouldn't be crashing
the compiler.

Minimal repro:

// m-part.mxx
export module m:part;

namespace kdeps
{
    export template < typename F >
    auto fun1(F)
    {
        return true;
    }

    using Dodgy = decltype([] {});

    export template < typename T >
    auto fun2(T&&)
    {
        return fun1(Dodgy{});
    }
}

// m.mxx
export module m;

export import :part;


Commands:
g++ -fPIC -Og -g -Wall std=c++2b -fmodules -finput-charset=UTF-8 -c -x c++
m-part.mxx
g++ -fPIC -Og -g -Wall std=c++2b -fmodules -finput-charset=UTF-8 -c -x c++
m.mxx


Output:
~/m.mxx:3:21: internal compiler error: tree check: expected tree that contains
‘typed’ structure, have ‘tu_local_entity’ in tree_node, at cp/module.cc:10128
    3 | export import :part;
      |                     ^
0x249029f internal_error(char const*, ...)
        ../../repo/gcc/diagnostic-global-context.cc:517
0x62815f tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ../../repo/gcc/tree.cc:9274
0x476706 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../repo/gcc/tree.h:3838
0x476706 tree_node
        ../../repo/gcc/cp/module.cc:10128
0x8b697c core_vals
        ../../repo/gcc/cp/module.cc:7324
0x8b697c tree_node_vals
        ../../repo/gcc/cp/module.cc:7680
0x8b4bf1 tree_value
        ../../repo/gcc/cp/module.cc:9722
0x8b4bf1 tree_node
        ../../repo/gcc/cp/module.cc:10066
0x8b66d1 core_vals
        ../../repo/gcc/cp/module.cc:6963
0x8b66d1 tree_node_vals
        ../../repo/gcc/cp/module.cc:7680
0x8b4bf1 tree_value
        ../../repo/gcc/cp/module.cc:9722
0x8b4bf1 tree_node
        ../../repo/gcc/cp/module.cc:10066
0x8b66d1 core_vals
        ../../repo/gcc/cp/module.cc:6963
0x8b66d1 tree_node_vals
        ../../repo/gcc/cp/module.cc:7680
0x8b4bf1 tree_value
        ../../repo/gcc/cp/module.cc:9722
0x8b4bf1 tree_node
        ../../repo/gcc/cp/module.cc:10066
0x8b78b4 core_vals
        ../../repo/gcc/cp/module.cc:7177
0x8b78b4 tree_node_vals
        ../../repo/gcc/cp/module.cc:7680
0x8b4bf1 tree_value
        ../../repo/gcc/cp/module.cc:9722
0x8b4bf1 tree_node
        ../../repo/gcc/cp/module.cc:10066


Build:
Target: x86_64-pc-linux-gnu
Configured with: ../repo/configure --prefix=/home/cjangus/gcc
--enable-languages=c,c++ --disable-multilib
gcc version 16.0.0 20250522 (experimental) (GCC)

Reply via email to