Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Argument checking

I discovered a bug in my code where a subroutine was expecting an array of integer*8 as an argument and was being passed an array of integer*4 and bad things started happening in the latter half of the array. After fixing this I began to wonder why the compiler did not catch this and save me from a morning of debugging. I tried compiler flags -check all and -warn all and still got nothing. Is there a way to check for the correctness of argument types? I'm using ifort 16.0.0 for Linux.

0 Kudos
1 Reply
Highlighted

-warn all includes -warn

-warn all includes -warn interface, which can warn you about such things, but it is dependent on the compilation order. If the calling routine is compiled before the called routine, it won't detect a mismatch. Best practice is to have all called procedures in modules - this guarantees that argument checking will occur.

Retired 12/31/2016
0 Kudos