Bug#1085986: modules: compiling inline defined function results in internal compiler error
Package: g++-14
Version: 14.2.0-6
Severity: normal
Dear Maintainer,
* What led up to the situation?
After converting a C++ header file to a module-defining source file the
compiler failed to compile it and reports an internal compiler error
* What exactly did you do (or not do) that was effective (or
ineffective)?
First /usr/include/c++/14/thread was compiled in that directory using the
commands
g++ --std=c++26 -pthread -Wall -fdiagnostics-color=never -fmodules-ts \
-c -x c++-header pthread
mv gcm.cache/,/pthread.gcm .
Then in the directory containing the file modraw.cc (shown next) phtread.gcm
was made available using:
mkdir gcm.cache
ln -s /usr gcm.cache
This is the file modraw.cc:
export module Mod;
export import <thread>;
class ModStr
{
static bool thread_local s_lastFail;
public:
static bool lastFail();
};
inline bool ModStr::lastFail()
{
return s_lastFail;
}
and the following compilation command was used:
g++ --std=c++26 -Wall -c -fmodules-ts modraw.cc
* What was the outcome of this action?
Compilation failed with the following error message:
modraw.cc:1:8: internal compiler error: in tree_node, at cp/module.cc:9455
1 | export module Mod;
| ^~~~~~
0x7f9c7145ad67 __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f9c7145ae24 __libc_start_main_impl
../csu/libc-start.c:360
* What outcome did you expect instead?
I expected the compilation to succeed. Apparently specifying the inline
definition of the 'static bool lastFail()' function below the class interface
resulted in the error. If instead its definition is provided in-class then
compilation succeeds. Here's the adapted 'modraw.cc' source:
export module Mod;
export import <thread>;
class ModStr
{
static bool thread_local s_lastFail;
public:
static bool lastFail()
{
return s_lastFail;
}
};
-- System Information:
Debian Release: trixie/sid
APT prefers testing
APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.11.2-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages g++-14 depends on:
ii g++-14-x86-64-linux-gnu 14.2.0-6
ii gcc-14 14.2.0-6
ii gcc-14-base 14.2.0-6
g++-14 recommends no packages.
Versions of packages g++-14 suggests:
pn g++-14-multilib <none>
pn gcc-14-doc <none>
-- no debconf information
Reply to: