public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56015] New: Option -ffast-math reveals i*(a+bi) -> -b-bi, a complex multiplication bug
@ 2013-01-17  8:40 t_nissie at yahoo dot co.jp
  2013-01-17  8:52 ` [Bug middle-end/56015] expand expands p[9] = COMPLEX_EXPR <-IMAGPART_EXPR <p[9]>, REALPART_EXPR <p[9]>>; incorrectly pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: t_nissie at yahoo dot co.jp @ 2013-01-17  8:40 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56015
           Summary: Option -ffast-math reveals i*(a+bi) -> -b-bi, a
                    complex multiplication bug
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: t_nissie@yahoo.co.jp


With gfortran, optimization option "-O3 -ffast-math", more
precisely "-O3 -funsafe-math-optimizations -ffinite-math-only"
reveals a complex multiplication bug of
i*(a+bi) =
Good: -b+ai
Bug:  -b-bi

Source:
! multiplyi.f -*-f90-*-
!!
program multiplyi
  implicit none
  complex*16 p(10)
  p(:) = (0.1d0, 0.2d0)
  p(:) = (0.0d0, 1.0d0) * p(:)
  write(6,'(2f5.1)') p(1)
end program multiplyi

Compilation and execution:
$ gfortran --version
GNU Fortran (GCC) 4.7.2
$ gfortran -ffree-form -O3 -o nofast-math multiplyi.f && ./nofast-math
  -0.2  0.1
$ gfortran -ffree-form -O3 -ffast-math -o fast-math multiplyi.f && ./fast-math
  -0.2 -0.2

Details:
 * I could reproduce this bug with gcc-4.4.6, 4.6.3, and 4.7.2.
 * I could reproduce it on Intel Core i5 and Xeon5650 (64bit)
   and VIA C7-M (32bit).
 * To reproduce this bug, the variable p(10) should not be an
   array in 4.6.3, but it should be an array in 4.7.2.

Tank you for your constant efforts on gfortran,
Takeshi


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

end of thread, other threads:[~2013-04-03 18:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-17  8:40 [Bug fortran/56015] New: Option -ffast-math reveals i*(a+bi) -> -b-bi, a complex multiplication bug t_nissie at yahoo dot co.jp
2013-01-17  8:52 ` [Bug middle-end/56015] expand expands p[9] = COMPLEX_EXPR <-IMAGPART_EXPR <p[9]>, REALPART_EXPR <p[9]>>; incorrectly pinskia at gcc dot gnu.org
2013-01-17 10:30 ` [Bug middle-end/56015] [4.6/4.7/4.8 Regression] " jakub at gcc dot gnu.org
2013-01-17 10:31 ` jakub at gcc dot gnu.org
2013-01-17 10:48 ` rguenth at gcc dot gnu.org
2013-01-17 11:58 ` t_nissie at yahoo dot co.jp
2013-01-18 17:15 ` jakub at gcc dot gnu.org
2013-01-18 17:26 ` [Bug middle-end/56015] [4.6/4.7 " jakub at gcc dot gnu.org
2013-02-01 14:11 ` jakub at gcc dot gnu.org
2013-02-01 14:32 ` [Bug middle-end/56015] [4.6 " jakub at gcc dot gnu.org
2013-04-03 18:20 ` jakub at gcc dot gnu.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).