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

ifort -check ate my children: why no check if arg list call matches declaration?

nooj
Beginner
462 Views
"-check all" or "-warn all" should check the number of arguments in subroutine calls.
why doesn't it?

i have inherited a hundred thousand line legacy code where the subroutines have an average of fifteen variables on the argument lists.

argument list checking (type, kind, rank, whatever) should have the option of being more thorough.

this is ifort version 10.1.


-----------example code below---------------------------------------

program arg_list
call three_args(1,2,3) ! correct
call three_args(1,2,3,4) ! incorrect, no warning, no crash
call three_args(1,2) ! incorrect, no warning, crashes
end


subroutine three_args(a,b,c)
integer a,b,c
write(*,*) "a,b,c: ",a,b,c
end


-----------ifort produces no warning or error-------------------------

nooj@localhost:~$ make
rm -rf a.out*
ifort -C arg-list.f -o a.out-C
ifort -C -warn arg-list.f -o a.out-C-warn
ifort -warn arg-list.f -o a.out-warn
nooj@localhost:~$
nooj@localhost:~$
nooj@localhost:~$ ifort --version
ifort (IFORT) 10.1 20080602
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.

nooj@localhost:~$


-------------but the program crashes---------------------

nooj@localhost:~$ ./a.out-C-warn
a,b,c: 1 2 3
a,b,c: 1 2 3
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out-C-warn 0000000000402BE8 Unknown Unknown Unknown
a.out-C-warn 00000000004029E2 Unknown Unknown Unknown
libc.so.6 00007F0D55F9E1C4 Unknown Unknown Unknown
a.out-C-warn 0000000000402929 Unknown Unknown Unknown
nooj@localhost:~$
0 Kudos
4 Replies
TimP
Honored Contributor III
462 Views
That's the purpose of the options -gen-interfaces -warn-interfaces options. I suppose you could argue they might be included under -check, but I'm in no position to debate that.
0 Kudos
Kevin_D_Intel
Employee
462 Views
Tim is correct.

Also, Steve recently added (here) that in a future release, -gen-interfaces will not need to be separately specified.

-check options are run-time checks and-warn options are compile-time checks. Interface checking is performed at compile-time and thus is not appropriate under -check.
0 Kudos
nooj
Beginner
462 Views
Thanks, Tim. Gold star for you. What I find frustrating is the following:

"-warn interfaces" does NOT catch the error unless there has been an interface generated (perhaps by "-gen-interfaces"). If there is an interface, it DOES catch the error.

So, using the above example, just the command

ifort -warn arg-list.f

gives no error, but

ifort -gen-interfaces arg-list.f
ifort -warn arg-list.f

does!

I specifically remember looking at "-warn interfaces" and moving on because I did not know of "-gen-interfaces" (despite having grepped the ifort man page for "argument" and similar terms).

It's good to see that -gen-interfaces will not need to be separately required. I needed that change badly, as I only recently noticed that I inherited a bad bug. It's been throwing off my results for a long time now.

- Nooj

0 Kudos
rreis
New Contributor I
462 Views
I think the "use -gen-interfaces -warn-interfaces" must be the best-seller in this forum :)
0 Kudos
Reply