------- Comment #2 from pinskia at gcc dot gnu dot org 2007-04-21 23:49 ------- This is not a bug in GCC but instead a bug in your post fix increment operator: C & operator++( int ) { v += 100; return *this; }
Really should be implemented as: C operator++( int ) { C tmp = *this; v += 100; return tmp; } Which is the correct way of implementing it. postfix increment returns a rvalue and not a lvalue. See example in the C++ standard in 13.5.7/1. Basically you just changed the semantics of post fix increment with the operator overloader and changed it to be about the same as the pre incrementor except incrementing by 100 instead of by 1. Again this is not a bug in GCC but instead a bug in your code. b = a++; is the same as doing: b = a.operator++(0); So if your operator++(int) returns *this, the result you are seeing is exactly what is expected from the C++ standards point of view. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31652