public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/50957] New: complex<T> ctor drops sign of zero (sometimes)
@ 2011-11-02  8:24 kreckel at ginac dot de
  2011-11-02  9:37 ` [Bug c++/50957] [C++0x][constexpr] " rguenth at gcc dot gnu.org
  2011-11-02  9:40 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: kreckel at ginac dot de @ 2011-11-02  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50957
           Summary: complex<T> ctor drops sign of zero (sometimes)
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kreckel@ginac.de


When compiling with -std=c++0x (and only then), the ctor of g++ drops the sign
of zero. (This sometimes devastates the correct choice of branch cuts in the
complex plain.) Interestingly, it doesn't happen with my mock complex class.

#include <iostream>
#include <complex>
using namespace std;

template<typename _Tp>
struct mock_complex
{
    typedef _Tp value_type;
    _GLIBCXX_CONSTEXPR mock_complex(const _Tp& __r = _Tp(), const _Tp& __i =
_Tp())
    : _M_real(__r), _M_imag(__i) { }
    const _Tp
    real() const { return _M_real; }
    const _Tp
    imag() const { return _M_imag; }
private:
    _Tp _M_real;
    _Tp _M_imag;
};

int main()
{
    mock_complex<double> z1(-0.0, 1.0);
    cout << signbit(z1.real()) << signbit(z1.imag()) << endl;  // correct: 10

    complex<double> z2(-0.0, 1.0);
    cout << signbit(z2.real()) << signbit(z2.imag()) << endl;  // wrong: 00
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-02  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-02  8:24 [Bug libstdc++/50957] New: complex<T> ctor drops sign of zero (sometimes) kreckel at ginac dot de
2011-11-02  9:37 ` [Bug c++/50957] [C++0x][constexpr] " rguenth at gcc dot gnu.org
2011-11-02  9:40 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).