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


             Bug #: 56318

           Summary: [4.6/4.7/4.8 Regression] Wrong result with MATMUL of

                    PARAMETER

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Keywords: wrong-code

          Severity: normal

          Priority: P3

         Component: fortran

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: bur...@gcc.gnu.org





Reported by Alberto Luaces at

http://gcc.gnu.org/ml/fortran/2013-02/msg00074.html



The code below should print the following - and it does with GCC 4.1/4.3/4.4

and NAG f95:

   0.333   0.000   0.000

   0.000   0.333   0.000

   0.000   0.000   0.000



However, with GCC 4.5/4.6/4.7/4.8, it prints:

   0.333   0.000   0.000

   0.000   0.000   0.333

   0.000   0.000   0.000





SUBROUTINE mass_matrix        

  DOUBLE PRECISION,PARAMETER::m1=1.d0

  DOUBLE PRECISION,DIMENSION(3,2),PARAMETER::A1=reshape([1.d0,0.d0, 0.d0, &

       0.d0,1.d0, 0.d0],[3,2])

  DOUBLE PRECISION,DIMENSION(2,2),PARAMETER::Mel=reshape([1.d0/3.d0, 0.d0, &

       0.d0, 1.d0/3.d0],[2,2])



  DOUBLE PRECISION,DIMENSION(3,3)::MM1



  MM1=m1*matmul(A1,matmul(Mel,transpose(A1)))

  print '(3f8.3)', MM1

  if (any (abs (MM1 &

                - reshape ([1.d0/3.d0, 0.d0,      0.d0,  &

                            0.d0,      1.d0/3.d0, 0.d0,  &

                            0.d0,      0.d0,      0.d0], &

                           [3,3])) > epsilon(1.0d0))) &

    call abort ()

END SUBROUTINE mass_matrix



program name

  implicit none

  call mass_matrix

end program name

Reply via email to