public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/56842] New: Argument deduction failure note is empty for alias template
Date: Thu, 04 Apr 2013 14:30:00 -0000	[thread overview]
Message-ID: <bug-56842-4@http.gcc.gnu.org/bugzilla/> (raw)


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

             Bug #: 56842
           Summary: Argument deduction failure note is empty for alias
                    template
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


For this code:

#include <type_traits>

struct Base { };

template<typename T>
struct Constraint1
: std::enable_if<std::is_base_of<Base, T>::value>
{ };

template <typename T,
         typename Requires = typename Constraint1<T>::type>
void foo() { }

struct A { };

int main()
{
    foo<A>();
}

GCC gives an excellent diagnostic:

b.cc: In function 'int main()':
b.cc:18:12: error: no matching function for call to 'foo()'
     foo<A>();
            ^
b.cc:18:12: note: candidate is:
b.cc:12:6: note: template<class T, class Requires> void foo()
 void foo() { }
      ^
b.cc:12:6: note:   template argument deduction/substitution failed:
b.cc:11:10: error: no type named 'type' in 'struct Constraint1<A>'
          typename Requires = typename Constraint1<T>::type>
          ^

However after changing it to use an alias template, which makes the declaration
of bar() much easier to read:

#include <type_traits>

struct Base { };

template<typename T>
  using Constraint2
    = typename std::enable_if<std::is_base_of<Base, T>::value>::type;

template <typename T,
         typename Requires = Constraint2<T>>
void bar() { }

struct A { };

int main()
{
    bar<A>();
}

GCC produces a useless diagnostic:

b.cc: In function 'int main()':
b.cc:16:12: error: no matching function for call to 'bar()'
     bar<A>();
            ^
b.cc:16:12: note: candidate is:
b.cc:10:6: note: template<class T, class Requires> void bar()
 void bar() { }
      ^
b.cc:10:6: note:   template argument deduction/substitution failed:


             reply	other threads:[~2013-04-04 14:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04 14:30 redi at gcc dot gnu.org [this message]
2013-04-11  2:41 ` [Bug c++/56842] " jason at gcc dot gnu.org
2020-11-10 17:48 ` redi at gcc dot gnu.org
2024-04-06 23:16 ` pinskia at gcc dot gnu.org

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