[Bug libstdc++/20758] operator-(const T&, const complex<T>&) vs operator-(const complex<T>&, const complex<T>&)

kreckel at ginac dot de gcc-bugzilla@gcc.gnu.org
Mon Apr 4 21:52:00 GMT 2005


------- Additional Comments From kreckel at ginac dot de  2005-04-04 21:52 -------
Subject: Re:  operator-(const T&, const complex<T>&) vs
 operator-(const complex<T>&, const complex<T>&)

I don't see how you can trigger wrong behaviour with
operator-(const complex<T> &lhs, const T &rhs):

  template<typename _Tp>
    inline complex<_Tp>
    operator-(const complex<_Tp>& __x, const _Tp& __y)
    {
      complex<_Tp> __r = __x;
      __r.real() -= __y;
      return __r;
    }

Isn't the unary operator- a necessary ingredient for the bug because it
silently changes the sign of zero?



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20758



More information about the Gcc-bugs mailing list