This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61806] New: [C++11] Expression sfinae w/o access gives hard error in partial template specializations
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 Jul 2014 09:10:36 +0000
- Subject: [Bug c++/61806] New: [C++11] Expression sfinae w/o access gives hard error in partial template specializations
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61806
Bug ID: 61806
Summary: [C++11] Expression sfinae w/o access gives hard error
in partial template specializations
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.kruegler at googlemail dot com
The following code, compiled with gcc 4.10.0 20140714 (experimental) using the
flags
-Wall -Wextra -std=c++11 -pedantic
or - alternatively -
-Wall -Wextra -std=c++1y -pedantic
//-----------------------
struct true_type
{
static const bool value = true;
};
struct false_type
{
static const bool value = false;
};
template<class T>
T&& declval();
template<typename> struct check { typedef void type; };
template<typename T, typename Enable = void>
struct has_public_f : false_type {};
template<typename T>
struct has_public_f<
T,
typename check<
decltype(
declval<T&>().f()
)
>::type
> : true_type {};
struct Spub { public: void f(); };
struct Spriv { private: void f(); };
static_assert( has_public_f<Spub>::value, "Ouch");
static_assert(!has_public_f<Spriv>::value, "Ouch");
int main() {}
//-----------------------
is rejected with the following diagnostics:
<quote>
prog.cc: In instantiation of 'struct has_public_f<Spriv>':
prog.cc:33:35: required from here
prog.cc:30:30: error: 'void Spriv::f()' is private
struct Spriv { private: void f(); };
^
prog.cc:27:15: error: within this context
> : true_type {};
^
prog.cc:30:30: error: 'void Spriv::f()' is private
struct Spriv { private: void f(); };
^
prog.cc:27:15: error: within this context
> : true_type {};
^
prog.cc:30:30: error: 'void Spriv::f()' is private
struct Spriv { private: void f(); };
^
prog.cc:33:16: error: within this context
static_assert(!has_public_f<Spriv>::value, "Ouch");
^
prog.cc:33:1: error: static assertion failed: Ouch
static_assert(!has_public_f<Spriv>::value, "Ouch");
^
</quote>
It seems that in this context there is no silent rejection of the partial
specialization, albeit it should.