- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Consider the following simple code snippet. Intel Fortran does give a warning if the procedure does not give a value to a dummy argument with an explicit INTENT(OUT) attribute. However a warning if such a variable is used before being defined is missing; it'll be very helpful if the compiler can warn for this situation as well.
module m implicit none contains subroutine foo(i) integer, intent(out) :: i print *, i return end subroutine foo subroutine bar(i) integer, intent(out) :: i print *, i i = 1 return end subroutine bar end module m
Compiling with Intel(R) Visual Fortran Compiler XE 15.0.3.208 [Intel(R) 64]... m.f90 C:\..\m.f90(7): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. Build log written to "file://C:\..\temp\Release\x64\p_BuildLog.htm" p - 0 error(s), 1 warning(s)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The warning that you did get is helpful, and the warning that you wish to see (but did not) would also be helpful, but compilers are easily mollified into not giving warnings when they see token assignments made with code such as the following.
If, prior to the PRINT statement on Line-9, you add "if(.false.)i = 77", the warning will go away, even though the variable i continues to be undefined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, and print or write may not catch the intent out thing, whereas an assignment statement with the not yet used intent(out) variable on rhs may be more picky.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My take is that I think the checking gives the warning only if it finds no assignment to an intent out arg which is relatively simple to do. To do more in general would get pretty complicated where there are multiple paths through the code and the assignment may or may not be happen. In some cases it would be only possible to determine this at run-time and there is a run-time check that can do this,
Whilst I agree such an error message might be helpful I suspect the effort required to achieve this (in the cases where is is possible) might be rather more effort than it is worth,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Only local scalar variables are currently checked for uninitialized before use.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page