https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120131

--- Comment #8 from Vladimir Terzi <vterzi1996 at gmail dot com> ---
I initially changed the status, because I assumed that my questions in comment
#2 will be ignored.

(In reply to kargls from comment #6)
> I suppose it is somewhat naive of gfortran contributors to expect that users
> read the documentation supplied with the compiler.

Not in the case of what is assumed to be common knowledge.  Most of Stack
Overflow users claimed that the correct integer*4 range in Fortran is
[-2147483648:2147483647].  This statement can even be found in Fortran language
references of Oracle and IBM.

(In reply to kargls from comment #6)
> ‘-fno-range-check’
>      Disable range checking on results of simplification of constant
>      expressions during compilation.  For example, GNU Fortran gives an
>      error at compile time when simplifying ‘a = 1. / 0’.  With this
>      option, no error is given and ‘a’ is assigned the value
>      ‘+Infinity’.  If an expression evaluates to a value outside of the
>      relevant range of [‘-HUGE()’:‘HUGE()’], then the expression is
>      replaced by ‘-Inf’ or ‘+Inf’ as appropriate.  Similarly, ‘DATA
>      i/Z'FFFFFFFF'/’ results in an integer overflow on most systems, but
>      with ‘-fno-range-check’ the value "wraps around" and ‘i’ is
>      initialized to -1 instead.
> 
> Those last two sentences are important.

I fail to see, how this two sentences explain that z'80000000' is an invalid
integer of kind 4 due to the Fortran standard.

(In reply to kargls from comment #6)
> % gfortran14 -o z -fno-range-check -pedantic a.f90 && ./z
> a.f90:1:21:
> 
>     1 | print *,  -2147483648
>       |                     1
> Warning: Integer outside symmetric range implied by Standard Fortran at (1)
>  -2147483648
> 
> So, yes, more than one gfortran contributor has thought about the corner
> case of -huge(1) - 1.

This is the message I would have wished to see as the error message in this
case.

Reply via email to