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

Unused variables checking

Paul_Curtis
Valued Contributor I
649 Views
The compiler's (v11.0.074, VS2008) criteria for "used" variables seem to include only that a variable appear in a statement with an equals sign, or as an argument to a function or subroutine, or as an array index. Specifically, a variable specified to be a pointer but not otherwise directly referenced is flagged as "unused". Consider the following:

[cpp]    SUBROUTINE DrawColorSwatch (locDIS, color)
        IMPLICIT NONE
        INTEGER, INTENT(IN)      :: locDIS
        INTEGER, INTENT(IN)      :: color
	INTEGER 		           :: rval
        TYPE(T_RECT)               :: clientRect
        
        TYPE(T_DRAWITEMSTRUCT)   :: dis
        POINTER(locDIS, dis)
        
        !   dummy assignment to fool the compiler's unused-variables checker
        rval = locDIS

        rval = GetClientRect (dis%hwndItem, clientRect)
	CALL fill_rectangle (dis%hDc, color, clientRect)
    END SUBROUTINE DrawColorSwatch
[/cpp]
If the rval=locDIS statement is commented out, the compiler produces
remark #7712: This variable has not been used. [LOCDIS].

This is not a show-stopper, but nonetheless mildly annoying. Is this problem fixable, or worth fixing?
TIA
0 Kudos
3 Replies
Steven_L_Intel1
Employee
649 Views
Amusing - I would have thought we'd find that one years ago. I'll report it - thanks.
0 Kudos
Steven_L_Intel1
Employee
649 Views
Fixed for a future release (not 11.1).
0 Kudos
Steven_L_Intel1
Employee
649 Views
Fixed in version 12
0 Kudos
Reply