https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120824
Bug ID: 120824
Summary: [modules] Cannot export unnamed enum declared in GMF
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: m.cencora at gmail dot com
Target Milestone: ---
$ cat sock_domain.h
#pragma once
extern "C"
{
enum
{
AF_INET,
AF_UNIX
};
}
$ cat posix.mod.cpp
module;
#include "sock_domain.h"
export module posix;
export
{
using ::AF_INET;
}
$ cat use.cpp
import posix;
int main()
{
AF_INET;
AF_UNIX;
}
$ g++ -fmodules posix.mod.cpp use.cpp
posix.mod.cpp:9:9: error: exporting ‘<unnamed enum> AF_INET’ that does not have
external linkage
9 | using ::AF_INET;
| ^~~~~~~
In file included from posix.mod.cpp:3:
sock_domain.h:8:5: note: ‘<unnamed enum> AF_INET’ declared here with no linkage
8 | AF_INET,
| ^~~~~~~
In module imported at use.cpp:1:1:
posix: error: failed to read compiled module: Nie ma takiego pliku ani katalogu
posix: note: compiled module file is ‘gcm.cache/posix.gcm’
posix: note: imports must be built before being imported
posix: fatal error: returning to the gate for a mechanical issue
It is a semi-regression compared to gcc 13/14 where posix.mod.cpp compiled
correctly, but the enum was still not visible for importers.
It works fine on clang-20 (I didn't test other versions).