- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the situation:
a = 1.0
z = 2.0
c = a + b
The "z" above is a typo. I really meant for it to be "b".
So because of thistypoinstead of getting c = 3.0, I will get c = 1.0.
I stillhave access to the old Compaq Visual Fortran v6.6 compiler. It issues the warning noted above, but I am unable to come up with a set of compiler options to force the warning in Intel Visual Fortran.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try the run-time flag /check:uninit. This catches most, sadly not all, such situations. {Also try /Qtrapuv; this flag initializes stack variables to an unsual value. In your case, you will not get c = 1. Note, however, that this can not be relied upon as in some cases the values will not be sufficiently unusal or else will go un-noticed.}
It may be a good idea to add /check:all to catch other problems as well.
Abhi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try enabling the sourcechecking (static verification) feature of Intel Visual Fortran:
Program uninit
a = 1.0
z = 2.0
c = a + b
print *, 'C=',c
end program uninit
>ifort /nologo /Qdiag-enable:sc3 uninit.f90
uninit.f90(3): warning #12178: this value of "Z" isn't used in the program
uninit.f90(4): error #12143: "B" is uninitialized
Run-time checking may be better for finding cases with more complex control flow. Currently, it only works for local, scalar variables (i.e., automatic scalar variables that are stored on the stack). I would certainly recommend /check:uninit over /Qtrapuv. For example,
>ifort /nologo /check:uninit /Qauto /traceback uninit.f90
>uninit
forrtl: severe (193): Run-Time Check Failure. The variable 'UNINIT$B' is being
used without being defined
Image PC Routine Line Source
uninit.exe 00448EDA Unknown Unknown Unknown
uninit.exe 004043B0 Unknown Unknown Unknown
uninit.exe 00404B92 Unknown Unknown Unknown
uninit.exe 00401041 _MAIN__ 4 uninit.f90
uninit.exe 0044EE73 Unknown Unknown Unknown
uninit.exe 004336C7 Unknown Unknown Unknown
kernel32.dll 763A3677 Unknown Unknown Unknown
ntdll.dll 77EA9D72 Unknown Unknown Unknown
ntdll.dll 77EA9D45 Unknown Unknown Unknown
But I also agree with the suggestion to use IMPLICIT NONE and to declare all your variables explicitly.
![](/skins/images/98E68944C1FF703B8AC50091329B92AF/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page