- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We are unable to get the compiler/linker to enforce argument list matching between caller of a subroutine/function and the subroutine/function itself. We only experience the problem when building from the command line. Is there a compiler/linker option that turns this enforcement on or implicitly turns it off? We are using Intel Fortran 9.1.033 and Visual Studio 2005 linker. The following example does not generate any errors or warnings:
SUBROUTINE A()
CALL B()
END
SUBROUTINE B(IVAL)
INTEGER*4 IVAL
IVAL = 6
END
We've attempted variations of the above code and cannot get the compiler/linker to flag this. Thanks for any assistance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C:MyProjects>ifort /gen-interface /warn:interface t.f90
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20070109
Z Package ID: W_FC_C_9.1.034
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
t.f90(2) : Error: A non-optional actual argument must be present when invoking a
procedure with an explicit interface. [IVAL]
CALL B()
--------^
compilation aborted for t.f90 (code 1)
If you used explicit interfaces, then you wouldn't need any switches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even with the options suggested, I still cannot see compile or link errors/warnings when I have mismatches between caller and callee argument lists. I've attached a demo app (note because I was limited to one file, I've simply concatenated the batch file and 2 source files - rename source files to TestDWS.for and TestSub.for):
Attached is 2 source files and a batch file that builds a one object library and then an exe. Note that TestDWS calls TestSub, and TestSub takes 3 parameters. Regardless of whether I call TestSub (i.e., from TestDWS) with 1, 2, or 3 arguments, the compile and link run fine. I do get a runtime error if the argument lists don't match, but this is a pain to find in a real program. What do you think?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to specify the switches when compiling all the sources, including those defining the subroutines. That's what provides information for the checking. Also, in the test you provided, you commented out the two bad calls. If I uncomment them and compile with the switches, I get this:
C:MyProjects>ifort /c /gen-interface /warn:interface testsub.for
Intel Fortran Compiler for 32-bit applications, Version 9.1
Build 20070109Z Package ID: W_FC_C_9.1.034
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
C:MyProjects>ifort /gen-interface /warn:interface testlib.for testsub.obj
Intel Fortran Compiler for 32-bit applications, Version 9.1
Build 20070109Z Package ID: W_FC_C_9.1.034
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
testlib.for(4) : Error: A non-optional actual argument must be present when invo
king a procedure with an explicit interface.
CALL TESTsub(I,J) ! too few calling arguments
-----------^
testlib.for(5) : Error: The number of actual arguments cannot be greater than th
e number of dummy arguments. [TESTSUB]
CALL TESTsub(I,J,K,L) ! too many calling arguments
-----------^
compilation aborted for testlib.for (code 1)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page