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

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