TL;DR version: fix your code.

On Tue, Mar 25, 2025 at 11:04:52AM -0400, NightStrike wrote:
> Between GCC 9 and 10, the following code now errors out:
> 

Did you read the Release Notes for 10.1?  Under the Fortran header:

    The handling of a BOZ literal constant has been reworked to provide
    better conformance to the Fortran 2008 and 2018 standards.  In these
    Fortran standards, a BOZ literal constant is a typeless and kindless
    entity.  As a part of the rework, documented and undocumented
    extensions to the Fortran standard now emit errors during compilation.
    Some of these extensions are permitted with the -fallow-invalid-boz
    option, which degrades the error to a warning and the code is compiled
    as with older gfortran. 

Note the use of "Some of these extensions ..."

> integer function fcn(x)
>   implicit none
>   integer, intent(in) :: x
>   fcn = x * '0100'X
> end function fcn
> 
> Error: BOZ constant at (1) uses nonstandard postfix syntax [see
> '-fno-allow-invalid-boz']
> Compiler returned: 1
> 
> First, the error message is wrong regarding the option to go see:
> 
> gfortran: error: unrecognized command-line option
> '-fno-allow-invalid-boz'; did you mean '-fallow-invalid-boz'?

Your 3-character patch is pre-approve for committing. 

Did you simply copuy-n-paste the option from the error message,
or did you actually read the documentation for the option?

‘-fallow-invalid-boz’
     A BOZ literal constant can occur in a limited number of contexts in
     standard conforming Fortran.  This option degrades an error
     condition to a warning, and allows a BOZ literal constant to appear
     where the Fortran standard would otherwise prohibit its use.

Feel free to update the manual to state that "allows a BOZ literal
constant to appear ***in some locations*** where the Fortran standard
would otherwise prohibit its use.

> Second, that option doesn't protect against the aforementioned case.

This statement makes no sense.  The option degrades an error
to a warning.

% gfcx -c a.f90
a.f90:4:19:

    4 |   fcn = x * '0100'X
      |                   1
Error: BOZ constant at (1) uses nonstandard postfix syntax
 [see '-fno-allow-invalid-boz']


gfcx -c -fallow-invalid-boz a.f90
a.f90:4:19:

    4 |   fcn = x * '0100'X
      |                   1
Warning: BOZ constant at (1) uses nonstandard postfix syntax

You now the error message,


a.f90:4:8:

    4 |   fcn = x * '0100'X
      |        1
Error: Operands of binary numeric operator '*' at (1) are INTEGER(4)/BOZ

which is the desired behavior as a BOZ is typeless and kindless.

> Third, and the main point of this email I guess, is that the
> porting-to page should mention this:
> https://www.gnu.org/software/gcc/gcc-10/porting_to.html

It's in the Release Notes.  Feel free write whatever porting
text you want.

Did you read section 5.1.0 of the gfortran manual?


If you got this far, "FIX YOUR CODE" or revert back
to GCC 9. 


-- 
Steve

Reply via email to