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

--- Comment #2 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #1)
> Looks like the programmer needs a few 'if (present(a)) then ... endif' block.
Yes. The programmer is me.

> 
> The code may be violating 
> 
>   F2023: 15.5.2.13 Argument presence and restrictions on arguments not
> present
>   ...
>   An optional dummy argument that is not present is subject to the following
>   restrictions.
> 
>     (1) If it is a data object, it shall not be referenced or be defined. ...
>     ...
>     (4) It shall not be supplied as an actual argument corresponding to a
>         nonoptional dummy argument other than as the argument of the
>         intrinsic function PRESENT or as an argument of a function
>         reference that is a constant expression.

Indeed.  It's never clear to me with inquiry functions.

    An intrinsic inquiry function is one whose result depends on the properties
    of one or more of its arguments instead of their values; in fact, these
    argument values may be undefined. Unless the description of an intrinsic 
    inquiry function states otherwise, these arguments are permitted to be
    unallocated allocatable variables or pointers that are undefined or
    disassociated. 

So unallocated allocatable and disassociated pointer are allowed, but there is
no mention of absent optional.  So it must be invalid.

Reply via email to