public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/30482]  New: <complex> division by 0
@ 2007-01-16 10:22 jakub at gcc dot gnu dot org
  2007-01-17  4:48 ` [Bug libstdc++/30482] " pcarlini at suse dot de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-01-16 10:22 UTC (permalink / raw)
  To: gcc-bugs

http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=221319
raises a question whether:
std::complex<double> (1.0, 1.0) / 0.0
and
std::complex<double> (1.0, 1.0) / std::complex<double> (0.0, 0.0)
can or can't be NaN.  In C say:
#define I (__extension__ 1.0iF)
_Complex double d = 1.0 + 0.0 * I, e, f, z = 0.0 + 0.0 * I;

int
main (void)
{
  e = d / 0.0;
  f = d / z;
  __builtin_printf ("%g %g %g %g\n", __real__ e, __imag__ e, __real__ f,
__imag__ f);
  return 0;
}
in -std=c99 always prints inf (where complex inf is even when just one of the
parts is inf), no matter what optimization options, in C89 the first division
when optimizing is usually optimized into the simpler __real__ d / 0.0,
__imag__ d / 0.0 division and thus gives inf too, but the latter and when not
optimizing
even the first one gives NaN.

What do we want in C++?  C++ doesn't use flag_complex_method = 2, so unless
that changes, only the division by double (rather than std::complex <double>)
could generally (when not optimizing) return inf - with a help in the
specialization, see the above URL.


-- 
           Summary: <complex> division by 0
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


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

end of thread, other threads:[~2007-07-11 10:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-16 10:22 [Bug libstdc++/30482] New: <complex> division by 0 jakub at gcc dot gnu dot org
2007-01-17  4:48 ` [Bug libstdc++/30482] " pcarlini at suse dot de
2007-07-05 22:28 ` pcarlini at suse dot de
2007-07-11 10:24 ` [Bug middle-end/30482] " pcarlini at suse dot de
2007-07-11 10:24 ` paolo at gcc dot gnu dot org

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).