[Bug c++/57466] New: Argument deduction fails for 'const T*' when T is function type
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 30 10:07:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57466
Bug ID: 57466
Summary: Argument deduction fails for 'const T*' when T is
function type
Product: gcc
Version: 4.7.3
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Blocks: 57465
(This is the root cause of PR 57465, but I have a workaround for the library.)
template<typename T>
constexpr bool
is_pointer(const T*)
{ return true; }
template<typename T>
constexpr bool
is_pointer(const T&)
{ return false; }
using F = void();
constexpr F* f = nullptr;
static_assert( is_pointer(f), "function pointer is a pointer" );
G++ fails the static assertion:
t.cc:15:1: error: static assertion failed: function pointer is a pointer
static_assert( is_pointer(f), "function pointer is a pointer" );
^
The first function template should be instantiated as bool is_pointer(F*) but
instead deduction fails because:
types 'const T' and 'F {aka void()}' have incompatible cv-qualifiers
Note deduction succeeds with an explicit template argument:
template<typename T>
constexpr bool
is_pointer(const T*)
{ return true; }
using F = void();
constexpr F* f = nullptr;
constexpr bool pass = is_pointer<F>(f);
constexpr bool fail = is_pointer(f);
More information about the Gcc-bugs
mailing list