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: unassig...@gcc.gnu.org ReportedBy: yacw...@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). =========================