This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59081] New: GCC should forbid using a private member datatype in template class
- From: "romain.geissler at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Nov 2013 20:55:23 +0000
- Subject: [Bug c++/59081] New: GCC should forbid using a private member datatype in template class
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59081
Bug ID: 59081
Summary: GCC should forbid using a private member datatype in
template class
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: romain.geissler at gmail dot com
Hi,
GCC should emit an error in the C class when referencing A::B in the following
code (as clang does).
class A{
private:
struct B{} _b;
};
template <typename T> class C{
public:
A::B* _b;
};
C<void> c;
Tested with gcc 4.8.2 and also the latest 4.9.0 trunk:
Using built-in specs.
COLLECT_GCC=/remote/intdeliv/seidelde/local/gcc/bin/../latest/bin/g++
COLLECT_LTO_WRAPPER=/remote/intdeliv/seidelde/local/gcc/4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-sources/configure --prefix
/remote/intdeliv/seidelde/local/gcc/4.8.2
--with-gmp=/remote/intdeliv/seidelde/local/gmp/5.1.3
--with-mpfr=/remote/intdeliv/seidelde/local/mpfr/3.1.2
--with-mpc=/remote/intdeliv/seidelde/local/mpc/1.0.1 --enable-lto
--disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 4.8.2 (GCC)
With clang I got the expected behavior:
rgeissler@ncegcolnx273:/tmp> ~seidelde/local/clang/bin/clang++ -c test.cpp
test.cpp:8:12: error: 'B' is a private member of 'A'
A::B* _b;
^
test.cpp:3:16: note: declared private here
struct B{} _b;
^
1 error generated.
Cheers,
Romain