[Patch, Fortran] PR34658 - More COMMON checks

Jerry DeLisle jvdelisle@verizon.net
Sun Jan 6 22:19:00 GMT 2008


Tobias Burnus wrote:
> Hi all,
> 
> Regarding blank commons in BLOCK DATA: I believe the following program
> is valid Fortran 95 and Fortran 2003, but gfortran currently gives
> "Warning: BLOCK DATA unit cannot contain blank COMMON at (1)" for:
> 
> block data bd
>  integer :: i
>  common //i
> end block data bd
> 
> I agree that the program is invalid as soon as "i" is initialized (e.g.
> "data i/5/"). NAG f95 gives a similar warning ("Warning: Blank common
> appears in BLOCK DATA BD"), but both do not check whether "i" is
> initialized. By comparison, g95 gives an error if "i" is initialized,
> but not if a not-initialized variable is used in a blank common.
> 
> Fortran 95 ("11.4 Block data program units"): "Only an object in a named
> common block may be initially defined in a block data program unit."
> 
> Fortran 2003 ("11.3 Block data program units"): "Only an object in a
> named common block may be initially defined in a block data program unit."
> 
> (Note: "defined" != "specified"; "defined (2.5.5): For a data object,
> the property of having or being given a valid value.")
> 
> On the other hand, one can argue that having COMMON blocks without
> initialization defeeds the purpose of block data: "A block data program
> unit is used to provide initial values for data objects in named common
> blocks." Nonetheless, I believe such programs are valid.
> 
> Therefore, I think the warning can be completely removed, which I did.
> One could also downgrade the warning to -Wsurprising, if someone thinks
> that is a better solution. See also PR 29537 which introduced this
> warning. Comments?
> 
>  * * *
> 
> The resolve.c part of the patch should be uncontroversial. It does:
> 
> - Check also constrains for blank commons
> 
> - Reject (with -std=f2003) initialized variables outside BLOCK DATA and
> in BLOCK DATA initialized variables in blank commons.
> 
> Currently, only with -std=f95 the program is rejected, one could also
> follow g95 and NAG f95 and emit always an error. ifort (without -stand
> f95) allows such programs, however.
> 
> Build and regtested on x86-64-linux; I get an ICE for common_6.f90 now
> also for -m32, but this is already tracked as PR33375.
> OK for the trunk?
> 
> Tobias
> 
OK, thanks for clarification on IRC.

Jerry



More information about the Fortran mailing list