[Bug c++/59372] New: accepts-invalid with constexpr function pointer variable as non-type template argument
richard-gccbugzilla at metafoo dot co.uk
gcc-bugzilla@gcc.gnu.org
Mon Dec 2 20:44:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59372
Bug ID: 59372
Summary: accepts-invalid with constexpr function pointer
variable as non-type template argument
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: richard-gccbugzilla at metafoo dot co.uk
Consider:
void f() {}
template<void (*)()> struct X {};
template<void (&)()> struct Y {};
constexpr void (*p)() = &f;
X<p> a;
constexpr void (*h())() { return &f; }
X<h()> b;
constexpr void (&q)() = f;
X<q> c;
constexpr void (&i())() { return f; }
X<i()> d;
GCC correctly rejects the types of 'b', 'c', and 'd', but fails to reject 'a'.
All four are ill-formed by 14.3.2/1. In particular, a non-type template
argument for a parameter of pointer type must be either a null pointer, the
name of a non-type template-parameter, or an expression of the form '&
id-expression', and the '&' can only be omitted if the id-expression names a
function or array. (See also the discussion for core issue 1570, where this
direction was reaffirmed.)
More information about the Gcc-bugs
mailing list