From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5777 invoked by alias); 15 Jul 2014 09:10:43 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5741 invoked by uid 48); 15 Jul 2014 09:10:38 -0000 From: "daniel.kruegler at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61806] New: [C++11] Expression sfinae w/o access gives hard error in partial template specializations Date: Tue, 15 Jul 2014 09:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: daniel.kruegler at googlemail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00943.txt.bz2 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 T&& declval(); template struct check { typedef void type; }; template struct has_public_f : false_type {}; template struct has_public_f< T, typename check< decltype( declval().f() ) >::type > : true_type {}; struct Spub { public: void f(); }; struct Spriv { private: void f(); }; static_assert( has_public_f::value, "Ouch"); static_assert(!has_public_f::value, "Ouch"); int main() {} //----------------------- is rejected with the following diagnostics: prog.cc: In instantiation of 'struct has_public_f': 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::value, "Ouch"); ^ prog.cc:33:1: error: static assertion failed: Ouch static_assert(!has_public_f::value, "Ouch"); ^ It seems that in this context there is no silent rejection of the partial specialization, albeit it should.