- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What did you use? As you can see it compiled for me just fine. My actual application does have interfaces defined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the explanation. That did fix the test case. Now to figure out my real application.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page