Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Perils of constants as arguments

$
0
0

I am writing a subroutine intended for redistribution to other coders in a static library:

Subname (irow, icol, ra, rb, ...)
   :
   IF (irow == 0) irow = INT(ra)
   IF (icol == 0) icol = (..something..)
   :
END Subname

The first two arguments, irow & icol (among others), are altered with the intent of returning updated values to the caller. The concern is that for some users, and in most cases, the routine case is

irow = 0
icol = 0
CALL Subname (irow, icol, ra, rb, ...)

But some lazy coders, thinking brevity is advantageous, will write

CALL Subname (0, 0, ra, rb, ...)

I know from my early days in F77 that this practice is a no-no and asks for trouble. There is info available on internet that the actual behavior is highly compiler-dependent and goes on to describe various unintended side effects that can happen. What is the situation with IVF? I have had mixed results. Should it always work, or never, or sometimes? How best to protect careless reusers of the library code against catastrophic crashes? It can probably be done via appropriate compiler switches in a debug build, but I need a release build with minimum baggage.

What is the best recommendation?


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>