public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51079] New: [C++0x] Conversion function template ignored in the presence of non-template conversion function
@ 2011-11-10 12:24 daniel.kruegler at googlemail dot com
  2011-11-10 20:34 ` [Bug c++/51079] " jason at gcc dot gnu.org
  2011-11-10 20:39 ` [Bug c++/51079] [C++0x] [DR 495] " jason at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-10 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51079
           Summary: [C++0x] Conversion function template ignored in the
                    presence of non-template conversion function
    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


gcc 4.7.0 20111105 (experimental) accepts the following code if compiled with
-Wall -std=c++0x:

//---
struct C1
{
  template <class T>
  operator T() = delete;
  operator bool() { return false; }
} c1;

struct C2
{
private:
  template <class T>
  operator T();
public:
  operator bool() { return false; }
} c2;

int ic1 = c1; // #1a
int ic2 = c2; // #1b

int ac1 = c1 + c1; // #2a
int ac2 = c2 + c2; // #2b
//---

After acceptance of the defect report

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#495

the lines #1a/b should be rejected, because the conversion function template
should deduce operator int as a better match, making these accesses ill-formed.

Similarly, #2a/b should be rejected, because there should be a manifold of
possible candidates for operator+.

Bug 49531 looks related, but I believe there are enough differences in the test
case to justify a separate report.


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

* [Bug c++/51079] [C++0x] Conversion function template ignored in the presence of non-template conversion function
  2011-11-10 12:24 [Bug c++/51079] New: [C++0x] Conversion function template ignored in the presence of non-template conversion function daniel.kruegler at googlemail dot com
@ 2011-11-10 20:34 ` jason at gcc dot gnu.org
  2011-11-10 20:39 ` [Bug c++/51079] [C++0x] [DR 495] " jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-10 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-10 20:28:26 UTC ---
Author: jason
Date: Thu Nov 10 20:28:16 2011
New Revision: 181270

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181270
Log:
    PR c++/51079, DR 495
    * call.c (joust): Check the second conversion sequence
    before checking templates.

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


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

* [Bug c++/51079] [C++0x] [DR 495] Conversion function template ignored in the presence of non-template conversion function
  2011-11-10 12:24 [Bug c++/51079] New: [C++0x] Conversion function template ignored in the presence of non-template conversion function daniel.kruegler at googlemail dot com
  2011-11-10 20:34 ` [Bug c++/51079] " jason at gcc dot gnu.org
@ 2011-11-10 20:39 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-10 20:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0
            Summary|[C++0x] Conversion function |[C++0x] [DR 495] Conversion
                   |template ignored in the     |function template ignored
                   |presence of non-template    |in the presence of
                   |conversion function         |non-template conversion
                   |                            |function

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-10 20:34:40 UTC ---
Fixed.


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

end of thread, other threads:[~2011-11-10 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-10 12:24 [Bug c++/51079] New: [C++0x] Conversion function template ignored in the presence of non-template conversion function daniel.kruegler at googlemail dot com
2011-11-10 20:34 ` [Bug c++/51079] " jason at gcc dot gnu.org
2011-11-10 20:39 ` [Bug c++/51079] [C++0x] [DR 495] " 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).