Description of problem: A complex arithmetic statement is compiled wrongly and produces the wrong result Version-Release number of selected component (if applicable): gcc-g77-3.4.6-3.1 How to reproduce: program bugtest implicit none complex*16 z z = dcmplx(1.0, 2.0) call sub(z) stop end program bugtest subroutine sub(z) implicit none complex*16 z z = dcmplx(-dimag(z), dreal(z)) write (6, *) z return end subroutine sub If you compile this without optimization (g77 bugtest.f -o bugtest) and run it you get the output (-2.,-2.) instead of (-2.,1.) It is pretty obvious what is happening: the important line (which implements z := iz) is being compiled as x := -y y := x which is pretty stupid. This problem does NOT occur for the more modern gfortran compiler, nor does it occur if you use any optimization flags (-O2, -O3 etc.) Examination of the machine code shows that indeed the result of x := -y overwrites x before the value is read for the calculation of y.
Created attachment 151415 [details] gcc34-rh233941.patch So far very lightly tested fix.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2007-0803.html