Bug#1081132: g++-14: Modules compiled with --std=c++23 can't be used with --std=c++26 and v.v.
Package: g++-14
Version: 14.2.0-3
Severity: normal
Dear Maintainer,
* What led up to the situation?
When trying to import a module in a C++ source file when --std=c++23 was
specified when the module was compiled and --std=c++26 is specified when the
source file is compiled the compiler shows the following error message:
Module: error: language dialect differs ‘C++23/coroutines’, expected ‘C++26/coroutines’
Module: error: failed to read compiled module: Bad file data
Module: note: compiled module file is ‘gcm.cache/Module.gcm’
Module: fatal error: returning to the gate for a mechanical issue
compilation terminated.
When --std=c++26 was specified when the module was compiled the compiler does
not show an error message.
* What exactly did you do (or not do) that was effective (or
ineffective)?
The following source file (e.g., interface.cc) defines the module:
module Module;
export int value;
and the module is used in the following source file (e.g., fun.cc):
import Module;
void fun()
{
value = 10;
}
'interface.cc' was compiled using using
g++ --std=c++23 -fmodules-ts -c interface.cc
'fun.cc' was compiled using using
g++ --std=c++26 -fmodules-ts -c fun.cc
* What was the outcome of this action?
when compiling 'interface.cc' and 'fun.cc' using the mentioned g++ commands
the abovementioned error is reported. When using c++26 when compiling
interface.cc and c++23 when compiling fun.cc a comparable error is
reported. When specifying the same standard (either c++23 or c++26 when
compiling both files no error is reported.
* What outcome did you expect instead?
Normally specifying a more recent C++ standard then files compiled with an
older standard can still be used. I would have expected the same situation
when compiling/using modules. Maybe it's just the switch from c++23 to c++26,
and will the error disappear when combining c++26 and the standard following
c++26, but if not, then we may have to recompile all already compiled modules
or all source files using modules once a new standard becomes available, which
is -let's say- inconvenient.
-- System Information:
Debian Release: trixie/sid
APT prefers testing
APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 6.10.6-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.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++-14 depends on:
ii g++-14-x86-64-linux-gnu 14.2.0-3
ii gcc-14 14.2.0-3
ii gcc-14-base 14.2.0-3
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: