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

Why does the PRESENT function not work in debug?

dajum
Novice
702 Views

I have attached a test program.  It works fine if I just build it.  But if I use /Od ( ifort /Od test.for) in the build it crashes and doesn't work correctly.  I noticed building my real application that in debug mode it would step into if tests if the argument being tested as PRESENT wasn't present.  So I would get crashes there as well when code that shouldn't be executed was.  Is this a compiler bug or is something wrong with my code? I'm using 2021.5. 

TIA

Dave

0 Kudos
1 Solution
andrew_4619
Honored Contributor II
694 Views

It doesn't compile.

error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [BUG]

error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [N]

 

The external subroutine has optional args, the main program needs to be told that by means of an interface or putting the subroutine in a module and USEing it.

View solution in original post

5 Replies
andrew_4619
Honored Contributor II
695 Views

It doesn't compile.

error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [BUG]

error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [N]

 

The external subroutine has optional args, the main program needs to be told that by means of an interface or putting the subroutine in a module and USEing it.

dajum
Novice
687 Views

What did you use? As you can see it compiled for me just fine. My actual application does have interfaces defined.

dajum_0-1653569038942.png

 

0 Kudos
mecej4
Honored Contributor III
678 Views

Andrew is correct. The program is non-conforming, since it calls an external routine that takes OPTIONAL arguments, and does so without providing an interface. Whether it "runs fine" or crashes, or gives wrong results, is unpredictable. Many such errors may go unnoticed for years, but surface some day. You noticed something odd about the behavior of the program in the debugger, but you did not suspect a connection to the absence of the interface. That is why when using optional arguments or other features that make an interface obligatory, note that requirement and provide the interface as part of your build procedure.

 

Compile with /warn:interfaces and you will receive the error message.

 

 

test.for(7): error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source.   [BUG]
       call bug(a,b)
------------^
test.for(8): error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source.   [N]
       call bug(a,b,n)
--------------------^
compilation aborted for test.for (code 1)

 

 

 

0 Kudos
Steve_Lionel
Honored Contributor III
676 Views

Andrew is correct that an explicit interface is missing but is required due to the OPTIONAL argument. (See Doctor Fortran Gets Explicit - Again! - Doctor Fortran (stevelionel.com)) The source compiles for you because you haven't specified /warn:interfaces, which is the default in a Visual Studio debug configuration but not on the command line.

The lack of an explicit interface means that the compiler doesn't know it has to pass a zero address for the omitted argument, and thus the subroutine sees whatever was in memory at that position.

0 Kudos
dajum
Novice
675 Views

Thanks for the explanation.  That did fix the test case.  Now to figure out my real application.

0 Kudos
Reply