[Bug c++/67080] New: Access to private using declaration incorrectly allowed
mwarusz at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jul 31 15:30:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67080
Bug ID: 67080
Summary: Access to private using declaration incorrectly
allowed
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mwarusz at gmail dot com
Target Milestone: ---
Sample code:
template <typename T>
struct A
{
struct N { };
};
template <typename T>
class B : public A<T>
{
using parent_t = A<T>;
public:
struct N : parent_t::N { };
};
template <typename T>
void f()
{
typename B<T>::N n; // comment out for correct error
typename B<T>::parent_t a;
}
int main()
{
f<int>();
}
This compiles using g++ -std=c++11 even though parent_t is a private member of
B. If the indicated line is commented out gcc correctly says that:
bug.cpp: In instantiation of ‘void f() [with T = int]’:
bug.cpp:25:10: required from here
bug.cpp:10:24: error: ‘using parent_t = struct A<int>’ is private
using parent_t = A<T>;
^
bug.cpp:20:27: error: within this context
typename B<T>::parent_t a;
Compiler details:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-5.2.0/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --disable-multilib --disable-werror
--enable-checking=release --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.2.0 (GCC)
More information about the Gcc-bugs
mailing list