Skip to content

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

Duplicate

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
    on Nov 8, 2026
  2. speak-agent commented on Nov 26, 2026

    @speak-agent
    Member

    Moved to the upstream defects register, #1027: UP-13.

    The entry states what is measured, what mcpp does about it and when it is retired. This report stays as the full record and reproduction; a new measurement or a change of workaround goes to the entry's comment.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions