Skip to content

gcc 16.1: ICE when an importer compares a module type whose operator== is a defaulted friend #910

Open

Description

@Sunrisepeak

Observation

Observed while building mcpp-community/mtest 0.4.0 (manifest/tests/listing.cpp). GCC 16.1.0 ends with an internal compiler error (segmentation fault) when a translation unit imports a module that exports a type with a defaulted friend comparison, and the importer compares two values of that type.

// manifest.cppm
export module mcpplibs.mtest.manifest;
import std;
export namespace mcpplibs::mtest::manifest {
struct static_bound {
    std::string metric;
    std::optional<double> max, min;
    friend bool operator==(const static_bound&, const static_bound&) = default;
};
}

// listing.cpp
import std;
import mcpplibs.mtest.manifest;
bool same(const mcpplibs::mtest::manifest::static_bound& a,
          const mcpplibs::mtest::manifest::static_bound& b) { return a == b; }
In module mcpplibs.mtest.manifest, imported at listing.cpp:2:
manifest.cppm:7:17: internal compiler error: Segmentation fault
    7 |     friend bool operator==(const static_bound&, const static_bound&) = default;

The code above is the shape of the failing units, not a verified minimal reduction. The interface unit compiles; the importer fails. The toolchain is gcc@16.1.0 with mcpp's import std.

Workaround

An explicit member comparison compiles and behaves the same (mcpp-community/mtest 0.4.0, manifest/src/manifest.cppm):

bool operator==(const static_bound& o) const {
    return metric == o.metric && max == o.max && min == o.min;
}

Status

The defect is in GCC. The report upstream is pending; mcpp has nothing to change, and a project meets it only through the compiler.

Activity

  1. added
    upstream-bug根因在上游(编译器/构建工具/依赖),mcpp 只能绕过或声明为缺口
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-bug根因在上游(编译器/构建工具/依赖),mcpp 只能绕过或声明为缺口

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions