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: unassig...@gcc.gnu.org
        ReportedBy: daniel.krueg...@googlemail.com
                CC: ja...@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.

Reply via email to