[Bug c++/51213] [C++11][DR 1170] Access control checking has to be done under SFINAE conditions
w.shane.grant at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Jun 23 20:28:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
Shane <w.shane.grant at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |w.shane.grant at gmail dot com
--- Comment #16 from Shane <w.shane.grant at gmail dot com> ---
I think some variant of this bug may still exist (using g++ (Ubuntu
4.8.1-2ubuntu1~13.04) 4.8.1). The following code will fail to compile under
g++ but will correctly compile under a recent version of clang++ (3.3).
template <class T>
T && declval();
template <class T>
constexpr auto hasSize(int) -> decltype(declval<T&>().size(), bool())
{ return true; }
template <class T>
constexpr bool hasSize(...)
{ return false; }
struct A
{
int size();
};
struct B : private A
{
};
static_assert(hasSize<A>(0), "A");
static_assert(!hasSize<B>(0), "B");
int main() {}
The error produced is:
test.cpp: In substitution of ‘template<class T> constexpr decltype
((declval<T&>().size(), bool())) hasSize(int) [with T = B]’:
test.cpp:22:28: required from here
test.cpp:5:61: error: ‘A’ is not an accessible base of ‘B’
constexpr auto hasSize(int) -> decltype(declval<T&>().size(), bool())
^
test.cpp: In substitution of ‘template<class T> constexpr decltype
((declval<T&>().size(), bool())) hasSize(int) [with T = B]’:
test.cpp:22:28: required from here
test.cpp:5:61: error: ‘A’ is not an accessible base of ‘B’
More information about the Gcc-bugs
mailing list