I would like to ask for clarification on the following case:
- I have a procedure interface with several versions in module
- Another subroutine, which has an
optional
argument, may call different procedures of the interface whether the argument is present or not. - the optional argument is
character(len=*)
I find that (with all major compilers! see test program at this link) when the object is not present, the procedure of the interface that assumes it is input is called, while I would expect it is not.
In my example, I am preparing a string:
label = value
if label is presentvalue
if label is not present
With all compilers I always get the =
sign, even if label is not present:
call print_optional(123)
call print_optional(123,'my_label')
returns
=123
my_label=123
I’m surprised: it means that the procedure with the character argument in the interface is always called. I would expect the program to go to the procedure without character argument instead:
123
my_label=123
Is this a bug across all compilers, or (more likely) I am missing some rules with optional character arguments? Thanks for any advice!