Bug#1120951: g++-15: Compilation error about class not being a non-union class type for valid C++ code
Package: g++-15
Version: 15.2.0-8
Severity: important
Tags: upstream
Dear Maintainer,
the recently uploaded version of g++ caused compilation errors in some packages
during rebuils, e.g. opm-simulators [1].
This simple C++ program fails to compile:
#include <set>
template <class S>
class A
{
typedef S VertexSet;
public:
typename VertexSet::size_type size();
private:
VertexSet vertices_;
};
template <class S>
inline typename A<S>::VertexSet::size_type A<S>::size()
{
return vertices_.size();
}
int main()
{
A<std::set<int>> a;
return a.size();
}
with the error:
<source>:16:55: error: 'class A<S>::VertexSet' resolves to 'A<S>::VertexSet',
which is not a non-union class type [-Wtemplate-body]
16 | inline typename A<S>::VertexSet::size_type A<S>::size()
| ^
Compiler returned: 1
See also [2].
The expected outcome would be that the program compiles without any errors.
One can work around this problem by defining a typename size_type for
VertexSet::size_type and using that instead. A similar fix has been applied to
dune-istl in [3]
Best,
Markus
[1] https://buildd.debian.org/status/fetch.php?pkg=opm-
simulators&arch=loong64&ver=2025.10%2Bds-1%2Bb1&stamp=1763168796&raw=0
[2] https://godbolt.org/z/xodooafea
[3] https://salsa.debian.org/science-team/dune-
istl/-/commit/51fedd3623c511f79ef5c2c6321fb62b9c08b5cf
-- System Information:
Debian Release: 12.12
APT prefers oldstable-updates
APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.1.0-40-amd64 (SMP w/64 CPU threads; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.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
Reply to: