This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Roger Sayle wrote: [...]
where we clearly call the function ia(), the X argument, multiple times. When this function has side-effects, we can end up generating incorrect results. In the middle-end, we'd normally use a SAVE_EXPR to handle this, but the gfortran scalarizer conveniently provides a gfc_evaluate_now function for this purpose. If I could write FORTRAN, I might even have attempted a new testcase for the testsuite.
! { dg-do run }
! At one point, SIGN() evaluated its first argument twice.
program sign1
integer :: i = 1
if (sign(foo(i), 1) /= 1) call abort
if (sign(foo(i), -1) /= -1) call abort
contains
integer function foo(i)
integer :: i
foo = i
i = i + 1
end function
end| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |