This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82478] Rejects valid access to private member type that should be allowed by friend
- From: "zamazan4ik at tut dot by" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Feb 2018 22:06:52 +0000
- Subject: [Bug c++/82478] Rejects valid access to private member type that should be allowed by friend
- Auto-submitted: auto-generated
- References: <bug-82478-4@http.gcc.gnu.org/bugzilla/>
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;