| 1 |
// { dg-do run } |
| 2 |
// { dg-options "-O2 -w" } |
| 3 |
// egcs-bugs 1999-02-22 14:24 Stefan Schwarzer |
| 4 |
// [email protected] |
| 5 |
// optimizer problem in egcs <= 1.1.1 |
| 6 |
|
| 7 |
struct XTVec{ |
| 8 |
XTVec(){x[0]=x[1] =x[2] =0;} |
| 9 |
XTVec(int ax,int y=0.,int z=0.){x[0]=ax;x[1]=y; x[2]=z; } |
| 10 |
int& operator[](int); |
| 11 |
|
| 12 |
int x[3]; |
| 13 |
}; |
| 14 |
|
| 15 |
inline |
| 16 |
int & XTVec::operator[](int i){ |
| 17 |
return x[i]; |
| 18 |
} |
| 19 |
|
| 20 |
inline |
| 21 |
XTVec& operator+=(XTVec& lhs, XTVec& rhs){ |
| 22 |
lhs[0]+=rhs[0]; |
| 23 |
lhs[1]+=rhs[1]; |
| 24 |
lhs[2]+=rhs[2]; |
| 25 |
return lhs; |
| 26 |
} |
| 27 |
|
| 28 |
inline |
| 29 |
XTVec operator+(XTVec& lhs, XTVec& rhs){ |
| 30 |
XTVec result(lhs); |
| 31 |
return result += rhs; |
| 32 |
} |
| 33 |
|
| 34 |
int main() |
| 35 |
{ |
| 36 |
XTVec ur(4.,0.,1.); |
| 37 |
XTVec ll(0.,2.,0.); |
| 38 |
XTVec initsum(ur + ll); |
| 39 |
|
| 40 |
// sum of components should be 7 |
| 41 |
return (initsum[0] + initsum[1] + initsum[2] - 7); |
| 42 |
} |