This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77368] New: Private static member visible to templated subclass
- From: "albin.olsson at volvocars dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Aug 2016 15:06:22 +0000
- Subject: [Bug c++/77368] New: Private static member visible to templated subclass
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77368
Bug ID: 77368
Summary: Private static member visible to templated subclass
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: albin.olsson at volvocars dot com
Target Milestone: ---
The following code is accepted by g++, but only if B is a templated class:
struct A
{
private:
static const int private_of_A = 5;
};
template <typename T>
struct B : public A
{
int get()
{
return private_of_A;
}
};
int main()
{
B<int> b;
return b.get();
}
This problem exists for all version of gcc I tested, which are:
x86-64 gcc 4.8.4
x86-64 gcc 6.2 (g++ ('Compiler) 6.2.0)
ARM64 gcc 4.8 (aarch64-linux-gnu-g++ (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.1)
5.4.0 20160609)
The two latter ones via https://gcc.godbolt.org/#