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: unassig...@gcc.gnu.org ReportedBy: t_nis...@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