This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] Handling of .and. and .or. expressions
Point taken! However will you warn for
-1<=x .and. x<=1
x>0.0 .and. y>0.0
… ?
If yes, this will be an incredible noise. If no, what about
-1<=x .and. x<=1 .and. asin(x)<1.0
x>0.0 .and. y>0.0 .and. log(x+y)<0.0
Dominique
> Le 14 juin 2018 à 07:15, Thomas Koenig <tkoenig@netcologne.de> a écrit :
>
> Am 13.06.2018 um 22:46 schrieb Dominique d'Humières:
>>>> In addition I don’t understand the associated warning: in short-circuit evaluation ASSOCIATED(m) (or ALLOCATED(m)) does protect m%T to be accessed.
>>>
>>> That is the whole point: Fortran does not have short circuit evaluation.
>>> Very many people assume that it does (or that everything is always
>>> evaluated), and this causes latent bugs.
>> I don’t understand. Short-circuit evaluation is explicitly allowed by the standard.
>
> Also legal are:
>
> Short-circuit evaluation in reverse order, parallel evaluation,
> evaluation of both expressions in the order they appear or evaluation
> of both expressions in reverse order (I think I have all cases there,
> but I may have missed one :-)
>
> The problem is that the user should not depend on it, and
> a compiler is free to chose whatever is most suited.
>
> Regards
>
> Thomas