Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29286 Discussions

presence of optional arguments in dummy argument specification

AAK
Novice
1,711 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
1,647 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 III
1,698 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
1,693 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
1,648 Views

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

0 Kudos
Devorah_H_Intel
Moderator
1,510 Views

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

Reply