Re: Request to improve docs: Fortran integer ranges vs. machine representation

2024-01-28 Thread Elias Toivanen
Guys, it's unproductive to discuss GFortran internals or the nuances of the standard with an end-user like me ;-) AFAIK, the implementation is compliant and correct. My angle here was completely different. The question is whether this aspect of Fortran leads to confusion and subsequently to dup

Re: Request to improve docs: Fortran integer ranges vs. machine representation

2024-01-26 Thread Steve Kargl
On Fri, Jan 26, 2024 at 11:38:01PM +0100, FX Coudert wrote: > > Interesting example. > > > > % gfcx -o z a.f90 && ./z > > -128 > > % gfcx -o z -pedantic a.f90 && ./z > > a.f90:5:20: > > > >5 | data j /-128_int8/ > > |1 > > Error: Integer too big for its kind at (1)

Re: Request to improve docs: Fortran integer ranges vs. machine representation

2024-01-26 Thread FX Coudert
> Interesting example. > > % gfcx -o z a.f90 && ./z > -128 > % gfcx -o z -pedantic a.f90 && ./z > a.f90:5:20: > >5 | data j /-128_int8/ > |1 > Error: Integer too big for its kind at (1). This check can be disabled with > the option ‘-fno-range-check’ That qualifi

Re: Request to improve docs: Fortran integer ranges vs. machine representation

2024-01-26 Thread Steve Kargl
On Fri, Jan 26, 2024 at 09:23:56PM +0100, FX Coudert wrote: > > This is, for example, legal code (and handled by gfortran as expected): > > use iso_fortran_env > implicit none > integer(int8) :: j > data j /-128_int8/ > print *, j > end > Interesting example. % gfcx -o z a.f90 &&

Re: Request to improve docs: Fortran integer ranges vs. machine representation

2024-01-26 Thread FX Coudert
>> print *, -128_int8 > > This is a unary minus operator with an operand of 128. > gfortran does not have negative integers. To be clear, it’s not gfortran, it’s the standard(s). It’s not exactly true either, because there is a "signed-int-literal-constant” which is allowed in some contexts:

Re: Request to improve docs: Fortran integer ranges vs. machine representation

2024-01-26 Thread Steve Kargl
On Fri, Jan 26, 2024 at 03:44:26PM +0200, Elias Toivanen wrote: > > I stumbled upon a Fortran quirk regarding the ranges for integers. > The standard stipulates that the ranges be symmetric even though > as we know two's complement signed integers have asymmetrical > ranges, e.g. int8 kind can var