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 duplicate bug reports and other such noise, which 
is away from your precious time. If so, the way the error messages are worded 
and the way your docs are written play a crucial role in mitigating the issue.

Enabling the `-pedantic` flag in myself, in the listing (primary.cc:286 
<http://primary.cc:286/>) 

```
if (gfc_range_check (e) != ARITH_OK)
    {
      gfc_error ("Integer too big for its kind at %C. This check can be "
                 "disabled with the option %<-fno-range-check%>");

      gfc_free_expr (e);
      return MATCH_ERROR;
    }
```

the if-block will be entered for any of the current and future error codes, 
while the error message only talks about the magnitude of the input.

If on the other hand you deem that working on this is not worth the effort, the 
issue is naturally resolved. 


--
Best regards / Ystävällisesti
Elias Toivanen
elias.a.toiva...@gmail.com


> On 27. Jan 2024, at 0.38, FX Coudert <fxcoud...@gmail.com> 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). This check can be disabled with 
>> the option ‘-fno-range-check’
> 
> That qualifies as a compiler bug, I think. Our documentation for -pedantic 
> states: “Issue warnings for uses of extensions to Fortran.” and "Valid 
> Fortran programs should compile properly with or without this option.”
> 
> The same is true of the following, which is also valid Fortran since 95 :
> 
> use iso_fortran_env
> implicit none
> complex, parameter :: z = (-128_int8, -128_int8)
> print *, z
> end
> 
> Right now it fails to compile with -pedantic.
> 
> Or are they illegal because of how the range should be be symmetric? I can’t 
> quite find the language in the standard for that, actually. To me, they’re 
> valid signed-int-literal-constant.
> 
> FX
> 
> 
> PS: I’m going to ignore the cases of the P and DT edit descriptors, because 
> they’re not allowed to have a kind value, and therefore the corner cases 
> occur for values too big to be actually relevant to anything.


Reply via email to