| 1 |
// { dg-do assemble } |
| 2 |
// GROUPS passed miscellaneous |
| 3 |
//The program listed below produces the following error during compilation: |
| 4 |
// % g++ bug17.cc |
| 5 |
// bug17.cc: In method `class Y& Y::operator = (const class Y&)': |
| 6 |
// bug17.cc:18: invalid use of non-lvalue array |
| 7 |
|
| 8 |
class X { |
| 9 |
public: |
| 10 |
X& operator=(const X&) { return *this; } |
| 11 |
}; |
| 12 |
|
| 13 |
struct S { |
| 14 |
char c[10]; |
| 15 |
X x; |
| 16 |
}; |
| 17 |
|
| 18 |
class Y { |
| 19 |
S s; |
| 20 |
public: |
| 21 |
const S& f() const { return s; } |
| 22 |
|
| 23 |
Y& operator=(const Y& _Y) { |
| 24 |
s = _Y.s; // this line compiles |
| 25 |
s = _Y.f(); // this line does not compile |
| 26 |
return *this; |
| 27 |
} |
| 28 |
}; |