public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57466] New: Argument deduction fails for 'const T*' when T is function type
@ 2013-05-30 10:07 redi at gcc dot gnu.org
  2013-05-30 11:03 ` [Bug c++/57466] " daniel.kruegler at googlemail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-30 10:07 UTC (permalink / raw)
  To: gcc-bugs

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);


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-01-09  0:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30 10:07 [Bug c++/57466] New: Argument deduction fails for 'const T*' when T is function type redi at gcc dot gnu.org
2013-05-30 11:03 ` [Bug c++/57466] " daniel.kruegler at googlemail dot com
2013-05-30 11:23 ` [Bug c++/57466] [DR 1584] " redi at gcc dot gnu.org
2014-07-08 10:21 ` paolo.carlini at oracle dot com
2014-07-09 21:23 ` paolo at gcc dot gnu.org
2014-07-09 21:24 ` paolo.carlini at oracle dot com
2014-08-15 16:24 ` paolo at gcc dot gnu.org
2014-08-15 16:26 ` paolo.carlini at oracle dot com
2015-04-22 11:59 ` jakub at gcc dot gnu.org
2015-07-16  9:16 ` rguenth at gcc dot gnu.org
2021-08-05  3:14 ` pinskia at gcc dot gnu.org
2021-08-05 15:33 ` redi at gcc dot gnu.org
2022-01-09  0:46 ` pinskia at gcc dot gnu.org

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