summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C
blob: 0ec12cb30b2730fb794b9c44a5382326467a2ecd (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
28
// { dg-do assemble  }
// GROUPS passed miscellaneous
//The program listed below produces the following error during compilation:
//   % g++ bug17.cc
//   bug17.cc: In method `class Y& Y::operator = (const class Y&)':
//   bug17.cc:18: invalid use of non-lvalue array

class X {
public:
   X& operator=(const X&) { return *this; }
};

struct S {
   char c[10];
   X x;
};

class Y {
   S s;
public:
   const S& f() const { return s; }

   Y& operator=(const Y& _Y) {
      s = _Y.s;    // this line compiles
      s = _Y.f();  // this line does not compile
      return *this;
   }
};