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

            Bug ID: 125552
           Summary: internal compiler error: in instantiate_decl, at
                    cp/pt.cc:28843
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leander.schulten at tetys dot de
  Target Milestone: ---

See https://godbolt.org/z/jbEGzo1M5 

I have a c++23 modules project like this:
testModule.cpp:
```c++
export module testModule;
import std;
export {
    template <typename Tag>
    void trigger_bug()
    {
        std::vector<int> vec = {4, 3};
        auto it1 = vec.begin();
        auto it2 = vec.end();

        // Step 4: Force the compiler to instantiate the constrained
        // three-way comparison operator inside __normal_iterator
        auto result = it1 <=> it2;
    }
}
```
and then
consumer.cpp:
```c++
export module test;

import testModule;
import std;
void test() {
    trigger_bug<int>();
    std::vector<int> vec = {4, 3};
    auto it1 = vec.begin();
    auto it2 = vec.end();

    // Step 4: Force the compiler to instantiate the constrained
    // three-way comparison operator inside __normal_iterator
    auto result = it1 <=> it2;
}
```

With gcc trunc (cfb945957ee9acd561f71e592221e227c140cfe4 2026-06-01)
I get the following stacktrace:
```
/root/.vs/src2/... .cpp:35:32:   required from here
   35 |         tetys::trigger_bug<int>();
      |         ~~~~~~~~~~~~~~~~~~~~~~~^~
/root/.vs/src2/... :18:17: internal compiler error: in instantiate_decl, at
cp/pt.cc:28843
   18 |         if (it1 <=> it2 == std::strong_ordering::less)
      |             ~~~~^~~~~~~
0x2ba7caf internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:787
0xb6559b fancy_abort(char const*, int, char const*)
        ../../gcc/diagnostics/context.cc:1813
0x8a467b instantiate_decl(tree_node*, bool, bool)
        ../../gcc/cp/pt.cc:28843
0xc90afa mark_used(tree_node*, int)
        ../../gcc/cp/decl2.cc:6898
0xdfe77b tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/cp/pt.cc:22997
0xdfec8b tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/cp/pt.cc:22242
0xe20b4e tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/cp/pt.cc:21399
0xe20b4e tsubst_call_args
        ../../gcc/cp/pt.cc:21358
0xdfed04 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/cp/pt.cc:22250
0xe3073f tsubst_stmt
        ../../gcc/cp/pt.cc:20864
0xe33576 tsubst_stmt
        ../../gcc/cp/pt.cc:19990
0xe31390 tsubst_stmt
        ../../gcc/cp/pt.cc:19629
0xe32093 tsubst_stmt
        ../../gcc/cp/pt.cc:20055
0xe39906 tsubst_stmt
        ../../gcc/cp/pt.cc:19618
0xe39906 instantiate_body
        ../../gcc/cp/pt.cc:28723
0xe3a71c instantiate_decl(tree_node*, bool, bool)
        ../../gcc/cp/pt.cc:29016
0xe44bcb instantiate_pending_templates(int)
        ../../gcc/cp/pt.cc:29091
0xc94f36 c_parse_final_cleanups()
        ../../gcc/cp/decl2.cc:5899
0xf6a2c0 c_common_parse_file()
        ../../gcc/c-family/c-opts.cc:1448
/root/gcc-trunk-install/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1plus -quiet
-imultiarch x86_64-linux-gnu -MD
tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/commandLine.cpp.d -MF
tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/commandLine.cpp.o.d -MT
tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/commandLine.cpp.o
-D_GNU_SOURCE -D LIBENVPP_CHECKS_ENABLED=1 -D LIBENVPP_PLATFORM_UNIX=1 -D
LIBENVPP_PLATFORM_WINDOWS=0 -D LIBENVPP_TESTS_ENABLED=0 -D
_WIN32_WINNT=_WIN32_WINNT_WIN10 -D TOML_HEADER_ONLY=0 -isystem
/root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include
/root/.vs/src2/tetys2/lib/runtimeCore/commandLine.cpp
-fdeps-file=tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/commandLine.cpp.ddi
-fdeps-target=tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/commandLine.cpp.o
-quiet -dumpdir tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/ -dumpbase
commandLine.cpp.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g
-std=gnu++23 -fabi-version=0 -fmodules
-fmodule-mapper=tetys2/lib/runtimeCore/CMakeFiles/runtimeCore.dir/commandLine.cpp.o.modmap
-fdeps-format=p1689r5 -o /tmp/ccNvgq9k.s

```

Reply via email to