This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
- From: "Casey at Carter dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 22 Aug 2015 15:36:59 +0000
- Subject: [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
- Auto-submitted: auto-generated
- References: <bug-66957-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66957
Casey Carter <Casey at Carter dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Casey at Carter dot net
--- Comment #8 from Casey Carter <Casey at Carter dot net> ---
The fix for this bug seems to have broken N4381-style customization points
(http://wg21.link/n4381). To wit, this program used to compile:
template <class T> T&& declval();
namespace X {
namespace Y {
int f(auto&&);
struct fn {
constexpr auto operator()(auto&& o) const {
return f(o);
}
};
}
namespace {
constexpr auto f = Y::fn{};
}
struct A {};
struct B {
friend double f(B&);
};
}
static_assert(__is_same_as(int, decltype(X::f(declval<X::A&>()))));
static_assert(__is_same_as(double, decltype(X::f(declval<X::B&>()))));
but now results in the error "error: âfâ is not a member of âXâ" for both
static_asserts. It's possible to workaround the error be declaring the
anonymous namespace inline:
inline namespace {
constexpr auto f = Y::fn{};
}
It appears that the non-visible friend function f declared in B is incorrectly
blocking name lookup of X::f before the phase of lookup that considers
namespaces nominated by using directives (such as unnamed namespaces).