[Bug c++/58993] incorrectly accept access of protected member method from derived class template
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 27 14:18:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58993
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2013-11-05 00:00:00 |2018-2-27
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Warning-free testcase:
class base {
private:
void foo() { }
};
template <typename T>
struct bar : public base {
void test() {
(void) &base::foo; // should be rejected
}
};
template <>
struct bar<void> : public base {
void test() {
// &base::foo; // correctly rejected
}
};
int main() {
bar<int>().test();
bar<void>().test();
}
Still accepted by trunk.
Clang says:
58993.cc:9:23: error: 'foo' is a private member of 'base'
(void) &base::foo; // should be rejected
^
58993.cc:3:10: note: declared private here
void foo() { }
^
1 error generated.
and EDG says:
"58993.cc", line 9: error: function "base::foo" (declared at line 3) is
inaccessible
(void) &base::foo; // should be rejected
^
detected during instantiation of "void bar<T>::test() [with T=int]"
at line 21
1 error detected in the compilation of "58993.cc".
More information about the Gcc-bugs
mailing list