https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104231
Bug ID: 104231
Summary: private ignored in non-type template parameter
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
% cat test.cpp
class A
{
struct B
{
constexpr B (int) { }
void error () const { throw 0; }
};
};
template <A::B s> void foo () { s.error (); }
int main ()
{
foo <0> ();
}
% g++ -std=c++20 test.cpp
% ./a.out
terminate called after throwing an instance of 'int'
Aborted
Being a private member of A, B should not be accessible.
The exception thrown is just to prove that a B object is indeed constructed.