[Bug c++/82478] Rejects valid access to private member type that should be allowed by friend
zamazan4ik at tut dot by
gcc-bugzilla@gcc.gnu.org
Wed Feb 7 22:30:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82478
Alexander Zaitsev <zamazan4ik at tut dot by> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |zamazan4ik at tut dot by
--- Comment #6 from Alexander Zaitsev <zamazan4ik at tut dot by> ---
One more problematic case:
#include <type_traits>
class A {
int a;
friend class B;
};
class B {
public:
template <class T, class = void>
struct trait: std::false_type {};
template <class T>
struct trait<T, std::void_t<decltype(std::declval<T&>().a)>>:
std::true_type {};
};
int main() {
static_assert(B::trait<A>{});
return 0;
}
On clang(trunk) this code works well. On gcc(trunk) we have:
prog.cc: In function 'int main()':
prog.cc:15:61: error: 'int A::a' is private within this context
struct trait<T, std::void_t<decltype(std::declval<T&>().a)>>:
std::true_type {};
~~~~~~~~~~~~~~~~~~~^
prog.cc:4:9: note: declared private here
int a;
More information about the Gcc-bugs
mailing list