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.
29285 Discussions

Argument List Matching - Compiler/Linker Enforcement

mattintelnetfort
Beginner
557 Views

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.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
557 Views
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.

0 Kudos
mattintelnetfort
Beginner
557 Views

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

0 Kudos
Steven_L_Intel1
Employee
557 Views

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)
0 Kudos
Reply