Bug#1133179: g++-16: internal compiler error: in register_duplicate, at cp/module.cc:13054

Étienne Mollier <[email protected]> Fri, 10 Apr 2026 19:31:23 +0200
Newsgroups gmane.linux.debian.devel.gcc
Message-ID <adkz624sNGqEgMSt__29010.5915557191$1775842408$gmane$org@emlwks999.eu>
Package: g++-16
Version: 16-20260322-1
Severity: normal

Dear Maintainer,

A colleague (in Bcc to preserve their email address from spam
from scrapers of the BTS) identified an internal compiler error
affecting import of <memory> with modules support.  The error
does not appear with g++-15.  They suspect commit 10b8379
"[PATCH] libstdc++: Add smart ptr owner_equals and owner_hash"
to have revealed the problem, but they admit it may have simply
raised a pre-existing bug that remained dormant.

Symptoms look like:

	$ make
	g++-16 -std=gnu++26 -fmodules   -c -o qt.o qt.cpp
	g++-16 -std=gnu++26 -fmodules   -c -o failed_mod.o failed_mod.cpp
	In file included from failed_mod.cpp:3:
	minimal.h:56:13: internal compiler error: in register_duplicate, at cp/module.cc:13054
	   56 |     return {};
	      |             ^
	0x322e8ff internal_error(char const*, ...)
		../../src/gcc/diagnostic-global-context.cc:787
	0xf9e0cf fancy_abort(char const*, int, char const*)
		../../src/gcc/diagnostics/context.cc:1813
	0x114a416 register_duplicate
		../../src/gcc/cp/module.cc:13054
	0x11547a8 decl_value
		../../src/gcc/cp/module.cc:8819
	0x114a714 tree_node
		../../src/gcc/cp/module.cc:10437
	0x11536e6 module_state::read_cluster(unsigned int)
		../../src/gcc/cp/module.cc:17682
	0x11541cf module_state::load_section(unsigned int, binding_slot*)
		../../src/gcc/cp/module.cc:21516
	0x1154286 module_state::lazy_load(unsigned int, binding_slot*)
		../../src/gcc/cp/module.cc:22539
	0x114c245 tree_node
		../../src/gcc/cp/module.cc:11045
	0x115333b module_state::read_cluster(unsigned int)
		../../src/gcc/cp/module.cc:17519
	0x11541cf module_state::load_section(unsigned int, binding_slot*)
		../../src/gcc/cp/module.cc:21516
	0x1154286 module_state::lazy_load(unsigned int, binding_slot*)
		../../src/gcc/cp/module.cc:22539
	0x114c245 tree_node
		../../src/gcc/cp/module.cc:11045
	0x115333b module_state::read_cluster(unsigned int)
		../../src/gcc/cp/module.cc:17519
	0x11541cf module_state::load_section(unsigned int, binding_slot*)
		../../src/gcc/cp/module.cc:21516
	0x1154286 module_state::lazy_load(unsigned int, binding_slot*)
		../../src/gcc/cp/module.cc:22539
	0x11585fa lazy_load_pendings(tree_node*, tree_node*)
		../../src/gcc/cp/module.cc:22640
	0x125e987 instantiate_decl(tree_node*, bool, bool)
		../../src/gcc/cp/pt.cc:28601
	0x126923b instantiate_pending_templates(int)
		../../src/gcc/cp/pt.cc:28896
	0x10bbc8c c_parse_final_cleanups()
		../../src/gcc/cp/decl2.cc:5887
	/usr/libexec/gcc/x86_64-linux-gnu/16/cc1plus -quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE failed_mod.cpp -quiet -dumpbase failed_mod.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=gnu++26 -fmodules -fasynchronous-unwind-tables -o /tmp/ccXRarOv.s
	Please submit a full bug report, with preprocessed source (by using -freport-bug).
	Please include the complete backtrace with any bug report.
	See <file:///usr/share/doc/gcc-16/README.Bugs> for instructions.
	make: *** [<builtin>: failed_mod.o] Error 1

I have attached the reproducer files to the bug report.  In its
current state, the reproducer depends on:

  * g++-16
  * qt6-base-dev

but I guess there may be options to further reduce the scope.

Have a nice day,  :)
Étienne.


-- System Information:
Debian Release: forky/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.19.11+deb14-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages g++-16 depends on:
pn  g++-16-x86-64-linux-gnu  <none>
pn  gcc-16                   <none>
ii  gcc-16-base              16-20260322-1

g++-16 recommends no packages.

Versions of packages g++-16 suggests:
pn  g++-16-multilib  <none>
pn  gcc-16-doc       <none>

-- 
  .''`.  Étienne Mollier <[email protected]>
 : :' :  pgp: 8f91 b227 c7d6 f2b1 948c  8236 793c f67e 8f0d 11da
 `. `'   sent from /dev/pts/0, please excuse my verbosity
   `-    on air: Saga - Chase The Wind
failed_mod.cpp (text/x-c++src, 69 B)
module;

#include "minimal.h"

export module failed_mod;

import qt;
makefile (text/plain, 155 B)
CXX = g++-16
CXXFLAGS = -std=gnu++26 -fmodules

all: failed_mod.o
.PHONY: all

failed_mod.o: qt.o

clean:
	rm -vf *.o *.i
	rm -rvf gcm.cache
.PHONY: clean
minimal.h (text/x-chdr, 1.4 KB)
#ifndef QOBJECT_H
#define QOBJECT_H

#include <memory>

template<typename T>
struct QTypeInfo
{
    static constexpr bool isIntegral = true;
};

template<typename T>
struct QBasicAtomicInteger
{
    static_assert(QTypeInfo<T>::isIntegral, "template parameter is not an integral type");
};

class QObject;

struct QMetaObject
{
    const QObject* cast(const QObject* obj) const;
};

struct QByteArray
{
    QBasicAtomicInteger<int> at;
};

namespace std {
template<>
struct hash<QByteArray>
{};
}        // namespace std

template<typename Enum>
struct QFlags
{
    QFlags() {}
};

struct QMetaType
{
    enum class TypeFlag
    {
    };

    typedef QFlags<TypeFlag> TypeFlags;

    static int registerType(const QMetaObject* metaObject);
};

inline QFlags<int>
operator|(QMetaType::TypeFlag /*f1*/, QMetaType::TypeFlag /*f2*/) noexcept
{
    return {};
}

template<typename T>
struct CapabilitiesImpl;

struct QSequentialIterableImpl
{
    template<class T>
    QSequentialIterableImpl()
    {
        CapabilitiesImpl<T>::IteratorCapabilities | (1 << 4);
    }
};

template<>
struct QTypeInfo<QSequentialIterableImpl>
{};

class QObject
{
    static bool disconnect(const QObject* sender, const char* signal, const QObject* receiver, const char* member);

    bool disconnect(const char* signal, const QObject* receiver, const char* member) const;

    std::unique_ptr<int> d_ptr;
};

#endif // QOBJECT_H
qt.cpp (text/x-c++src, 112 B)
module;

#include "minimal.h"

export module qt;
export using QObject = ::QObject;

extern "C++" int
main()
{
}
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEj5GyJ8fW8rGUjII2eTz2fo8NEdoFAmnZM+sACgkQeTz2fo8N
Edq4Dg//ZJICKCknfMvWLO5YEtgKpuSRXS9xdfx9C8oiv0eXeZlN1bl+XItpfMGf
mrB4z0YeMDGASfYooBwf3rFhXs1r2cF6VNkj8+7zfqIXGQnZkH8vplm8N5sbDGvu
vFASeAvxpInDYaHZK2nvMFR62UWffWJHngeyR71z62d1tCG9iZ8NZXQykflzvome
xF6D1/4ryLF5OYheZX/sFgEtp2Y5G7UO5b856jzPXLClsOgTJ0jpTtLaoNp9W4Bc
XgtlKHeqGSSWMSNqPLVrDt9OsKD44GvA6e0ylC0IOM6s5iQKh5rhQanShn9Q6kJ0
WeFUcL71/VUKH7bj4+gPJzn8tQCtQXkvAb1H46dpagpvm450C+lBatYymgOjTu54
sOQY3ztwuOYtcZI4v97cSyAp9to26FdfbJXa6b9K7hV9bJSeObRQToo04tqtGIdq
eyeOMZvmntWpoY+5v5x7yLffn4UEkrsEPo7Cl7uYynfkGD9W7IzUm1kxzRG32FyL
mNWwlEtONqUeTZlu+sA8OFiVF/AyA1y4JFWDXFrvBOov+xzOk1G6YADHq0NNQDm0
aJIf+aZ42mTcxE6Dp/8rlUm54vpInpjoZddQ//S5IAcwUEAQLnbkh/HYpHr/8oB8
jj3JHLsJ3XYRerliR95BEfAbC9uk+MQlLCvmfA7+WFAGzg9H3nI=
=DwEY
-----END PGP SIGNATURE-----