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

            Bug ID: 57785
           Summary: DOT_PRODUCT error with constant complex array
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: konstant at mail dot ntua.gr

GNU Fortran (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
gcc         (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3

Code:

 print *, 'z.z= ',DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0),
(1.0, 4.0) /))
 print *, 'z.z= ',SUM(   CONJG((/ (1.0, 2.0), (2.0, 3.0) /))*(/ (1.0, 1.0),
(1.0, 4.0) /))

produces
 z.z=  ( -11.0000000    ,  14.0000000    )
 z.z=  (  17.0000000    ,  4.00000000    )

The first one is wrong. 

With GNU Fortran (Ubuntu 4.4.3-4ubuntu5) 4.4.3 the result is correct:

 z.z=  (  17.000000    ,  4.0000000    )
 z.z=  (  17.000000    ,  4.0000000    )

Generating complex numbers e.g.
 complex(8) :: z1(2),z2(2)
 real   (8) :: rez(2),imz(2)
 call random_number(rez);call random_number(imz);z1=DCMPLX(rez,imz)
 call random_number(rez);call random_number(imz);z2=DCMPLX(rez,imz)
 print *, 'z1.z2=',DOT_PRODUCT(z1,z2)
 print *, 'z1.z2=',SUM(DCONJG(z1)*z2)

produces correct results for many tries.

Reply via email to