Trying to use compiler diagnostics whenever possible so really trying to to give the compiler options
warn:all
check:all
a work out. ir seems to me that
Warn: Is a warning issued at compile time, hence static analysis. program execution NOT required.... find your errors before you check the source in.
Check: Is a run time verifications, hence dynamic analysis.... catch you errors in the software check out stage
Using my sample code:
--------------------------------------------------------------------
SUBROUTINE BadSub()
IMPLICIT NONE
INTEGER (KIND=4) I,LoopSize
REAL (KIND=4) ANumber
REAL (KIND=4) YetAnotherNumber
REAL (KIND=4) UnusedNumber
REAL (KIND=4) AnArray(5)
! If ANumber is commented out below then ...
! YetAnotherNumber=ANumber gives a runtime error
ANumber=2.
YetAnotherNumber=ANumber
! If LoopSize is greater that 5 the runtime error is trapped ...
LoopSize=5
! LoopSize=15
DO I=1,LoopSize
AnArray(I)=I*3.14159
END DO
PRINT 15
15 FORMAT(/1X,' Hello World subroutine')
write (*,*) ANumber
RETURN
! Can't reach this code
YetAnotherNumber=5.0
RETURN
END
------------------------------------------------
I can correctly find most run time errors i.e.
I had hope:
warn:uncalled Enables warnings when a statement function is never called.
would have found the issue with the statement after "Can't reach this code". If Uncalled can't find this just what is uncalled intended to do? I guess I was hoping for behavior similar to FORTRAN flint.
And frankly warning never caught the out of bounds or undefined issues, on the run time checking did.
Thoughts?
Regards
Carl
warn:all
check:all
a work out. ir seems to me that
Warn: Is a warning issued at compile time, hence static analysis. program execution NOT required.... find your errors before you check the source in.
Check: Is a run time verifications, hence dynamic analysis.... catch you errors in the software check out stage
Using my sample code:
--------------------------------------------------------------------
SUBROUTINE BadSub()
IMPLICIT NONE
INTEGER (KIND=4) I,LoopSize
REAL (KIND=4) ANumber
REAL (KIND=4) YetAnotherNumber
REAL (KIND=4) UnusedNumber
REAL (KIND=4) AnArray(5)
! If ANumber is commented out below then ...
! YetAnotherNumber=ANumber gives a runtime error
ANumber=2.
YetAnotherNumber=ANumber
! If LoopSize is greater that 5 the runtime error is trapped ...
LoopSize=5
! LoopSize=15
DO I=1,LoopSize
AnArray(I)=I*3.14159
END DO
PRINT 15
15 FORMAT(/1X,' Hello World subroutine')
write (*,*) ANumber
RETURN
! Can't reach this code
YetAnotherNumber=5.0
RETURN
END
------------------------------------------------
I can correctly find most run time errors i.e.
- forrtl: severe (193): Run-Time Check Failure. The variable 'BADSUB$ANUMBER' is being used without being defined
- forrtl: severe (408): fort: (2): Subscript #1 of the array ANARRAY has value 6 which is greater than the upper bound of 5
- hello_subroutine.f(8) : Info: This variable has not been used. [UNUSEDNUMBER] REAL (KIND=4) UnusedNumber
I had hope:
warn:uncalled Enables warnings when a statement function is never called.
would have found the issue with the statement after "Can't reach this code". If Uncalled can't find this just what is uncalled intended to do? I guess I was hoping for behavior similar to FORTRAN flint.
And frankly warning never caught the out of bounds or undefined issues, on the run time checking did.
Thoughts?
Regards
Carl
1 解決方案
warn:uncalled refers to statement functions. These are an ancient Fortran feature that is "deprecated" in the current Fortran standard. You are not using these in your code, so no warning. Here's an example:
Uninitialized variable checking is done at run-time only. Array bounds checking is MOSTLY done at run-time, but sometimes the compiler can see bounds errors with constant subscripts and will warn you at compile time.
I recommend that you also use /gen-interface which allows /warn:interface to work.
[plain]triple(y) = 3.0*y
quadruple(y) = 4.0*y
print *, triple(72.)
end
uncalled.f90(2): remark #7713: This statement function has not been used. [QUADRUPLE]
quadruple(y) = 4.0*y
^[/plain]
Uninitialized variable checking is done at run-time only. Array bounds checking is MOSTLY done at run-time, but sometimes the compiler can see bounds errors with constant subscripts and will warn you at compile time.
I recommend that you also use /gen-interface which allows /warn:interface to work.
連結已複製
2 回應
warn:uncalled refers to statement functions. These are an ancient Fortran feature that is "deprecated" in the current Fortran standard. You are not using these in your code, so no warning. Here's an example:
Uninitialized variable checking is done at run-time only. Array bounds checking is MOSTLY done at run-time, but sometimes the compiler can see bounds errors with constant subscripts and will warn you at compile time.
I recommend that you also use /gen-interface which allows /warn:interface to work.
[plain]triple(y) = 3.0*y
quadruple(y) = 4.0*y
print *, triple(72.)
end
uncalled.f90(2): remark #7713: This statement function has not been used. [QUADRUPLE]
quadruple(y) = 4.0*y
^[/plain]
Uninitialized variable checking is done at run-time only. Array bounds checking is MOSTLY done at run-time, but sometimes the compiler can see bounds errors with constant subscripts and will warn you at compile time.
I recommend that you also use /gen-interface which allows /warn:interface to work.
