strange function behavior

strange function behavior

Dear group,
the attached code, compiled with ifort, produces:

$ ifort test.f90
test.f90(12): (col. 3) remark: LOOP WAS VECTORIZED.
test.f90(13): (col. 3) remark: LOOP WAS VECTORIZED.
$ ./a.out
0.998238754750969 -1.277365851769966E-003 -4.179797816566392E-002
0.998238754750969 -1.279619575668178E-003 -4.191068882689722E-002

Notice that e3%x and e1%x are different. gfortran and g95 give the
same results for the two variables:

$ gfortran test.f90
$ ./a.out
0.998238754750969 -1.279619575668178E-003 -4.191068882689722E-002
0.998238754750969 -1.279619575668178E-003 -4.191068882689722E-002

which I think is the correct behavior. Is this a bug in ifort?
(My compiler:
$ ifort --version
ifort (IFORT) 10.1 20070913
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

Thank you, best regards
Marco Restelli

program test

implicit none

integer, parameter :: wp = selected_real_kind(12,307)
type cartesian_coordinates
real(wp) :: x(3)
end type cartesian_coordinates
type(cartesian_coordinates) :: e1, e2, e3

e1%x = (/ 1.0_wp , 0.0_wp , 0.0_wp /)
e2%x = (/ 4.196719253215153E-2_wp , &
3.049095015559707E-2_wp , &
0.998653621987913_wp /)
e3%x = e1%x - cc_dot_product(e1,e2)*e2%x
e1%x = e1%x - cc_dot_product(e1,e2)*e2%x

write(*,*) e1
write(*,*) e3


elemental function cc_dot_product(x1,x2) result(p_prod)
type(cartesian_coordinates), intent(in) :: x1, x2
real(wp) :: p_prod

p_prod = dot_product (x1%x,x2%x)

end function cc_dot_product

end program test

1 envío / 0 nuevos
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.