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

--- Comment #32 from Dominique d'Humieres <dominiq at lps dot ens.fr> 
2011-12-02 16:37:37 UTC ---
> And for the sake of completeness the evaluation of sub above and
>
>    subroutine sub2(x)
>      real*8 x
>      x = (x + 2.d0**52) - 2.d0**52
>    end subroutine sub2
>
> should behave consistently if I read your Fortran standard
> quotations correctly.

According my reading of

> "Once the interpretation of a numeric intrinsic operation is established, the
> processor may evaluate any mathematically equivalent expression, provided that
> the integrity of parentheses is not violated."

this is different from

>   subroutine sub(x)
>     real*8 x, tem
>     tem = x + 2.d0**52
>     x = tem - 2.d0**52
>   end subroutine sub

where 'x=tem-2.d0**52' can be evaluated as 'x=x+2.d0**52-2.d0**52' then as 'x'
(as long as x and tmp are of the same kind(?)), while in the former case '(x +
2.d0**52) - 2.d0**52' is prohibited by the standard to be evaluated as 'x'.

Note that if I replace 'tem = x + 2.d0**52' with 'tem = (x + 2.d0**52)', I get
1.0 unless I use -fno-protect-parens.

All this has been discussed previously, but the only pr I have been to find is
pr32172.

Reply via email to