This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++-4.0.3: program output is different when compiled with -O3 (did not happen with gcc-3.4.5)


Hi Erik,

I think you just need to rework your operator< a little bit, and you'll be
fine.

struct Coords {
  bool operator<(const Coords other) const {
    Uint32 lhs = (Uint32(x) << 16) | Uint32(y);
    Uint32 rhs = (Uint32(other.x) << 16) | Uint32(other.y);
    return lhs < rhs;
  }
   
  int x : 16, y : 16;
};

HTH.
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]