This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR 57160: short-circuit IF only with -ffrontend-optimize
2018-07-24 21:49 GMT+02:00 Thomas Koenig <tkoenig@netcologne.de>:
> Am 24.07.2018 um 20:46 schrieb Janus Weil:
>>
>> Good, since we all seem to agree on that, I'm including it in the
>> patch (new version in the attachment).
>
> Sorry for chiming in so late, but I don't (and Dominique doesn't
> either).
Dominique has not commented on the question whether -Og should imply
-ffrontend-optimization, therefore I don't know his opinion on that
matter.
> If you want to enforce either short-circuit evaluation or
> forced evaluation, please use a dedicated option.
I don't want to enforce any of that. gfortran is enforcing
short-circuiting right now (with any option), and I want to change
that.
> I don't think it is a good idea to have
>
> if (allocated(x) .and. any(x>0))
>
> crash on -O0 and not crash on -O.
I actually do. The code is invalid. Crashing it is good, because it
draws the user's attention to that fact.
You can find lots of invalid programs that change their behavior with
different optimization flags.
> -O should not change the semantics of a program in
> such a way.
You should thank the authors of the Fortran standard for not fixing
the semantics of and/or operands.
Note that -O will not change the results of valid code (except if
impure functions are involved, and those trigger a warning since
recently).
Cheers,
Janus