public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50157] New: [C++0x] Non-silent SFINAE in new expression with explicit conversion
@ 2011-08-22 19:19 daniel.kruegler at googlemail dot com
  2011-08-25 18:24 ` [Bug c++/50157] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-08-22 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50157
           Summary: [C++0x] Non-silent SFINAE in new expression with
                    explicit conversion
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@redhat.com
             Build: 4.7.0 20110813 (experimental)


gcc 4.7.0 20110813 (experimental) in C++0x mode rejects the following code:

---
template<class T>
T val();

template<class T, class Arg, class =
  decltype(::new T(val<Arg>()))
>
auto test(int) -> char;

template<class, class>
auto test(...) -> char (&)[2];

struct P {
  explicit operator bool(); // (#13)
};

typedef decltype(test<bool, P>(0)) type; // OK
typedef decltype(test<float, P>(0)) type2; // Error (#17)
---

"17|error: invalid user-defined conversion from 'P' to 'float' [-fpermissive]|
13|note: candidate is: P::operator bool() <near match>|
13|note:   return type 'bool' of explicit conversion function cannot be
converted to 'float' with a qualification conversion|
17|error: invalid user-defined conversion from 'P' to 'float' [-fpermissive]|
13|note: candidate is: P::operator bool() <near match>|
13|note:   return type 'bool' of explicit conversion function cannot be
converted to 'float' with a qualification conversion|
||=== Build finished: 6 errors, 0 warnings ===|"

It is correct, that the P->float conversion would be ill-formed, but this needs
to be handled silently and the program should be accepted. The compiler seems
to have a special problem here with the combination of an explicit conversion
function in P and the otherwise feasible bool->float conversion in implicit
contexts.


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

* [Bug c++/50157] [C++0x] Non-silent SFINAE in new expression with explicit conversion
  2011-08-22 19:19 [Bug c++/50157] New: [C++0x] Non-silent SFINAE in new expression with explicit conversion daniel.kruegler at googlemail dot com
@ 2011-08-25 18:24 ` jason at gcc dot gnu.org
  2011-08-25 18:30 ` jason at gcc dot gnu.org
  2011-08-25 18:58 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-25 18:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-25 18:22:49 UTC ---
Author: jason
Date: Thu Aug 25 18:22:46 2011
New Revision: 178081

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178081
Log:
    PR c++/50157
    * call.c (convert_like_real): Exit early if bad and !tf_error.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae27.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/50157] [C++0x] Non-silent SFINAE in new expression with explicit conversion
  2011-08-22 19:19 [Bug c++/50157] New: [C++0x] Non-silent SFINAE in new expression with explicit conversion daniel.kruegler at googlemail dot com
  2011-08-25 18:24 ` [Bug c++/50157] " jason at gcc dot gnu.org
@ 2011-08-25 18:30 ` jason at gcc dot gnu.org
  2011-08-25 18:58 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-25 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-25 18:22:36 UTC ---
Author: jason
Date: Thu Aug 25 18:22:33 2011
New Revision: 178080

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178080
Log:
    PR c++/50157
    * call.c (convert_like_real): Exit early if bad and !tf_error.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/sfinae27.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/call.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/50157] [C++0x] Non-silent SFINAE in new expression with explicit conversion
  2011-08-22 19:19 [Bug c++/50157] New: [C++0x] Non-silent SFINAE in new expression with explicit conversion daniel.kruegler at googlemail dot com
  2011-08-25 18:24 ` [Bug c++/50157] " jason at gcc dot gnu.org
  2011-08-25 18:30 ` jason at gcc dot gnu.org
@ 2011-08-25 18:58 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-25 18:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.6.2

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-25 18:53:01 UTC ---
Fixed for 4.6.2.


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

end of thread, other threads:[~2011-08-25 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-22 19:19 [Bug c++/50157] New: [C++0x] Non-silent SFINAE in new expression with explicit conversion daniel.kruegler at googlemail dot com
2011-08-25 18:24 ` [Bug c++/50157] " jason at gcc dot gnu.org
2011-08-25 18:30 ` jason at gcc dot gnu.org
2011-08-25 18:58 ` jason 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).