public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "richard-gccbugzilla at metafoo dot co.uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59056] enable_if turns a non-ambiguous template into an ambiguous one
Date: Wed, 13 Nov 2013 21:00:00 -0000	[thread overview]
Message-ID: <bug-59056-4-JEBDPRS7wA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59056-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
(In reply to Jonathan Wakely from comment #2)
> I thought if the partial specializations were ambiguous then these function
> overloads should be too.

Yes, this inconsistency is very surprising. GCC, EDG, and Clang all behave the
same way, and yet I can find no justification for this behavior in the
standard.

Morally, the function call should be ambiguous. The first 'func' takes Bar<X>
for any X where check<X>() is true, and the second 'func' takes Bar<X> for any
X that matches Foo<T>. Neither of those constraints implies the other, so the
call should be ambiguous.

In Clang's case, the problem is that we fail to enforce
[temp.deduct.type](14.8.2.5)/1 when partially ordering function templates -- we
don't check that deduction actually succeeded in finding types that make 'A'
match the 'deduced A' -- but we do check that when partially ordering class
templates, and we don't spot the problem earlier because the enable_if<...> is
a non-deduced context. I expect EDG and GCC have a similar bug.


  parent reply	other threads:[~2013-11-13 21:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-08 22:19 [Bug c++/59056] New: " walter.mascarenhas at gmail dot com
2013-11-08 22:35 ` [Bug c++/59056] " paolo.carlini at oracle dot com
2013-11-09 12:58 ` redi at gcc dot gnu.org
2013-11-11 11:37 ` redi at gcc dot gnu.org
2013-11-13 11:11 ` paolo.carlini at oracle dot com
2013-11-13 21:00 ` richard-gccbugzilla at metafoo dot co.uk [this message]
2013-11-13 23:16 ` [Bug c++/59056] ambiguous call to function templates overloads not diagnosed redi at gcc dot gnu.org
2013-11-14  2:26 ` [Bug c++/59056] ambiguous call to function template " walter.mascarenhas at gmail dot com
2013-11-14  3:04 ` richard-gccbugzilla at metafoo dot co.uk
2013-11-14 10:20 ` walter.mascarenhas at gmail dot com

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-59056-4-JEBDPRS7wA@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).