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
* [Bug c++/50957] [C++0x][constexpr] complex<T> ctor drops sign of zero (sometimes) 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 ` rguenth at gcc dot gnu.org 2011-11-02 9:40 ` paolo.carlini at oracle dot com 1 sibling, 0 replies; 3+ messages in thread From: rguenth at gcc dot gnu.org @ 2011-11-02 9:37 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50957 Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Keywords| |wrong-code Last reconfirmed| |2011-11-02 Component|libstdc++ |c++ CC| |jason at gcc dot gnu.org Ever Confirmed|0 |1 Summary|complex<T> ctor drops sign |[C++0x][constexpr] |of zero (sometimes) |complex<T> ctor drops sign | |of zero (sometimes) Known to fail| |4.6.2 --- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-11-02 09:36:44 UTC --- Confirmed. Looks like a frontend issue (probably related to constexpr?). In .initial we have { struct mock_complex z1 = {._M_real=-0.0, ._M_imag=1.0e+0}; struct complex z2 = {._M_value=__complex__ (0.0, 1.0e+0)}; <<cleanup_point struct mock_complex z1 = {._M_real=-0.0, ._M_imag=1.0e+0};>>; thus z2 is already initialized from a bogus value. Without -std=c++0x we have struct complex z2; <<cleanup_point <<< Unknown tree: expr_stmt std::complex<double>::complex (&z2, -0.0, 1.0e+0) >>>>>; which is correct. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/50957] [C++0x][constexpr] complex<T> ctor drops sign of zero (sometimes) 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 1 sibling, 0 replies; 3+ messages in thread From: paolo.carlini at oracle dot com @ 2011-11-02 9:40 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50957 Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-02 09:39:20 UTC --- This just PR48760 in a different form, mainline is fine. *** This bug has been marked as a duplicate of bug 48760 *** ^ 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).