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

presence of optional arguments in dummy argument specification

AAK
Novice
980 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
Honored Contributor III
916 Views

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

View solution in original post

0 Kudos
4 Replies
andrew_4619
Honored Contributor II
967 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?

 

 

 

 

0 Kudos
AAK
Novice
962 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.

0 Kudos
Steve_Lionel
Honored Contributor III
917 Views

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

0 Kudos
Devorah_H_Intel
Moderator
779 Views

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

Reply