aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C
blob: 3d4cc031e414925e0390373e6492f6cfb13d2da0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// { dg-do assemble  }
// Ambiguous conversion, three candidates:
// builtin == (int, int), and the two user-defined operators
// Each one requires a user-defined ICS where another uses builtin conversions,
// so none is the best viable function.

class MyInt
{
public:
        MyInt(int = 0) {}
        operator int() const {return 2;}
};

bool operator==(const MyInt& a, const int& b)
{                                               // { dg-error "" } candidate
        return (int)a == b;
}

bool operator==(const MyInt& a, const MyInt& b)
{                                               // { dg-error "" } candidate
        return (int)a == (int)b;
}

bool f()
{
  return 3 == MyInt();                          // { dg-error "" } ambiguous
}