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

Argument checking

koskela__tuomas
Beginner
228 Views

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
Steven_L_Intel1
Employee
228 Views

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

0 Kudos
Reply