public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yacwroy at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/53585] New: template value parameter of pointer-to-member type incorrectly rejects non-direct values
Date: Wed, 06 Jun 2012 01:15:00 -0000	[thread overview]
Message-ID: <bug-53585-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53585

             Bug #: 53585
           Summary: template value parameter of pointer-to-member type
                    incorrectly rejects non-direct values
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: yacwroy@gmail.com


Created attachment 27561
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27561
c++ testcase - should be legal

Problem:
Pointer-to-member value parameters appear to only accept direct values (of the
immediate form &X::Y) and reject passed constexpr variables.

llvm/clang++ accepts these.

I'm assuming this is legal but I haven't checked the standard.

specs: linux/x64

source (same as attached)
=========================
struct SFoo
    {
        int x;
    };

constexpr int SFoo::* G_ptr_to_x = &SFoo::x;

// Dummy test struct.
template <int SFoo::* P>
struct SBar {};

SBar<G_ptr_to_x> G_bar; // <ERROR>. (This should be legal, and is in clang).

// Additional testing:
SBar<&SFoo::x> G_bar2; // Shows the member-pointer works if immediate.
constexpr int SFoo::* another_ptr = G_ptr_to_x; // Shows "could not convert
..." error message is incorrect.

int main()
    {}
=========================
Errors (build command = g++ mptr.cpp -std=c++11).
=========================
test/misc/mptr.cpp:12:16: error: ‘G_ptr_to_x’ is not a valid template argument
for type ‘int SFoo::*’
 SBar<G_ptr_to_x> G_bar; // <ERROR>. (This should be legal, and is in clang).
                ^
test/misc/mptr.cpp:12:16: error: it must be a pointer-to-member of the form
‘&X::Y’
test/misc/mptr.cpp:12:16: error: could not convert template argument
‘G_ptr_to_x’ to ‘int SFoo::*’
test/misc/mptr.cpp:12:23: error: invalid type in declaration before ‘;’ token
 SBar<G_ptr_to_x> G_bar; // <ERROR>. (This should be legal, and is in clang).
=========================


             reply	other threads:[~2012-06-06  1:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06  1:15 yacwroy at gmail dot com [this message]
2012-06-06  7:49 ` [Bug c++/53585] " daniel.kruegler at googlemail dot com
2012-06-06 16:43 ` yacwroy at gmail dot com
2012-06-06 20:07 ` daniel.kruegler at googlemail dot com
2014-07-08  9:02 ` paolo.carlini at oracle dot com

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-53585-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).