Skip to content

GCC 16.1 segfaults compiling src/main.cpp when the module graph gains one module #863

Duplicate

Description

@Sunrisepeak

What happens

GCC 16.1.0 (the gcc@16.1.0 toolchain mcpp builds itself with) segfaults while compiling src/main.cpp (import mcpp.cli;) once the tree's module graph grows by one module. Measured while implementing the target sets of design 2026-10-29 (release/2026.10.30.1):

  • adding a new module to the tree, whatever its content, makes the compile of src/main.cpp end with an internal compiler error (segmentation fault);
  • the same happens with the unchanged src/cli/cmd_build.cppm plus one import of an existing, unrelated module (import mcpp.build.advice;);
  • removing that one import makes the tree compile again.

The failure follows the number of modules reachable from main.cpp, not the code added, which points at GCC's handling of a large transitive module graph rather than at any construct of ours.

Workaround in mcpp

The target-set code, the leg API and the test archive were placed in existing modules (mcpp.toolchain.triple, mcpp.build.prepare with prepare/legs.cpp as a partition implementation unit, mcpp.build.execute) rather than in new ones, so the module count reachable from main.cpp is unchanged.

To do

Reduce to a self-contained reproducer (a generated chain of N modules imported by one TU) and report it to GCC Bugzilla; record the GCC bug here; remove the placement constraint when a fixed GCC is the toolchain mcpp builds with.

Co-authored-by: speak-agent 248744407+speak-agent@users.noreply.github.com

Activity

  1. added
    upstream-bug
    on Oct 29, 2026
  2. cui3093 commented on Nov 5, 2026

    @cui3093

    When to upgrade to gcc 16.2?

  3. Sunrisepeak commented on Nov 7, 2026

    @Sunrisepeak
    MemberAuthor

    When to upgrade to gcc 16.2?

    there is a regression bug in gcc 16.2 for C++ modules, so mcpp is waiting for gcc 17.

  4. speak-agent commented on Nov 26, 2026

    @speak-agent
    Member

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

    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.

  5. Sunrisepeak commented on Nov 26, 2026

    @Sunrisepeak
    MemberAuthor

    When to upgrade to gcc 16.2?

    there is a regression bug in gcc 16.2 for C++ modules, so mcpp is waiting for gcc 17.

    @cui3093 try mcpp latest version, it is supported for gcc 16.2/17

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