| 1 |
// { dg-do run } |
| 2 |
// g++ 1.37.1 bug 900511_01 |
| 3 |
|
| 4 |
// g++ fails to properly apply user-defined type conversion operators |
| 5 |
// in cases where is it not obvious that the given conversion is |
| 6 |
// appropriate for the context (i.e. operator and other operands) |
| 7 |
// where the conversion should take place. |
| 8 |
|
| 9 |
// cfront 2.0 passes this test. |
| 10 |
|
| 11 |
struct struct_1 { |
| 12 |
int member; |
| 13 |
|
| 14 |
operator int (); |
| 15 |
}; |
| 16 |
|
| 17 |
struct_1::operator int () |
| 18 |
{ |
| 19 |
return 0; |
| 20 |
} |
| 21 |
|
| 22 |
struct struct_2 { |
| 23 |
int member; |
| 24 |
|
| 25 |
operator float (); |
| 26 |
}; |
| 27 |
|
| 28 |
struct_2::operator float () |
| 29 |
{ |
| 30 |
return 0.0; |
| 31 |
} |
| 32 |
|
| 33 |
struct_1 struct_1_object; |
| 34 |
struct_2 struct_2_object; |
| 35 |
double d; |
| 36 |
|
| 37 |
void test () |
| 38 |
{ |
| 39 |
d = struct_2_object + struct_1_object; // OK |
| 40 |
d = struct_1_object + struct_2_object; // { dg-bogus "" } |
| 41 |
} |
| 42 |
|
| 43 |
int main () { return 0; } |