public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-61806-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2014-07-15  9:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15  9:10 daniel.kruegler at googlemail dot com [this message]
2014-12-14  0:49 ` [Bug c++/61806] " ville.voutilainen at gmail dot com
2021-04-28 21:08 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61806-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).