Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27530 Discussions

presence of optional arguments in dummy argument specification

AAK
Novice
573 Views

Hi everyone,

I came across this minor bug (I guess), when optional dummy arguments are used in the specification of other dummy arguments:

subroutine s1(arg1,arg2)
implicit none  
integer, intent(in), optional :: arg1(:)
integer, intent(in), optional :: arg2(size(arg1))
end subroutine

subroutine s2(arg1,arg2)
implicit none  
integer, intent(in), optional :: arg1(:)
integer, intent(in), optional :: arg2(merge(size(arg1),0,present(arg1)))
end subroutine

While `s2` compiles with errors (as it should), `s1` does not result in errors in `ifort (IFORT) 2021.5.0 20211109`

gfortran (7.5.0) spits out errors for both routines.

 

Greetings

 

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
509 Views

I hope that one of the Intel folk pick this up and submit it as a bug.

View solution in original post

4 Replies
andrew_4619
Honored Contributor II
560 Views

I think that is probably not a compiler bug as such but you would get a run time error if the optional args were not present.  The code is not standard conforming but the compiler is not obliged to give errors for all non-conformances. It is nice to get errors for bad code though. Did you have standards checking switched on BTW?

 

 

 

 

AAK
Novice
555 Views

That's ok for me I just wanted to report the inconsistency.
Regarding your BTW: If you mean the `-stand` option, there's no difference compiling with or without it.

Steve_Lionel
Black Belt Retired Employee
510 Views

I hope that one of the Intel folk pick this up and submit it as a bug.

Devorah_H_Intel
Moderator
372 Views

This report has been escalated to compiler engineering - CMPLRLLVM-36112

Reply