From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E5970385840B; Sun, 19 Nov 2023 16:23:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5970385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700410992; bh=1x3HOeOij+YeshecV5usO6wh4kBmUDdHrl9jQ6J5i6I=; h=From:To:Subject:Date:From; b=QNAprcpNLAWvUg5j/wA10ZbRruZBaMdnqFeHvJTfs2hlBVNFac2ZlBpH3IrPdasN8 spAGc/D2Hfp9f3NatUz4AqJxYeOv6KlhOzLRf+p8E/iFd7EcThZVxEMlkBEKR4lsXB uoEdFkIcVmpU6FAgscptB1V8FkRydZGvIJV+EJeo= From: "amaikinono at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112621] New: g++ error: "references internal linkage entity" when compiling a module interface Date: Sun, 19 Nov 2023 16:23:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amaikinono at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112621 Bug ID: 112621 Summary: g++ error: "references internal linkage entity" when compiling a module interface Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: amaikinono at gmail dot com Target Milestone: --- Created attachment 56641 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D56641&action=3Dedit Preprocessed files. Here's a minimal example: ``` // class.cxx export module mod; const int default_val { 0 }; export class Example { // This line causes the problem. int value { default_val }; }; ``` Compile it: ``` $ g++ -c -std=3Dc++20 -fmodules-ts class.cxx class.cxx:5:14: error: =E2=80=98class Example=E2=80=99 references internal = linkage entity =E2=80=98const int default_val=E2=80=99 5 | export class Example | ^~~~~~~ class.cxx:1:8: error: failed to write compiled module: Bad file data 1 | export module mod; | ^~~~~~ class.cxx:1:8: note: compiled module file is =E2=80=98gcm.cache/mod.gcm=E2= =80=99 ``` If we don't use `default_val` in the class: ``` export module mod; const int default_val { 0 }; export class Example { int value { 0 }; }; ``` or if the file is not a module interface: ``` const int default_val { 0 }; class Example { int value { default_val }; }; ``` Then it compiles. I've also reported this at . Outputs of `gcc -v`: Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --enable-languages=3Dada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-boots= trap --prefix=3D/usr --libdir=3D/usr/lib --libexecdir=3D/usr/lib --mandir=3D/usr= /share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttps://bugs.archlinux.org/ --with-build-config=3Dbootstrap-lto --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-obj= ect --enable-libstdcxx-backtrace --enable-link-serialization=3D1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdc= xx-pch --disable-werror Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20230801 (GCC)=