Talking of UMRs...
We have been having a "discussion" with a user who is debugging a large code.
There are problems with uninitialised variables. We use compiler/loader
options to initialise memory to NaN, generating arithmetic exceptions
when accessed but
- there seem to be situations (allocate?) where this doesn't happen.
- doesn't work for integers (NaN may be large, but its legal)
User seems to think that compiler should analyse the control flow
and warn about "used before defined" at compile time. We have pointed
out the difficulties of generally not being able to determine flow of
control at compile time.:-{
Our current compilers usually pick some up if the logic is simple:
subroutine duh(a,n)
implicit none
real :: a,b
integer :: n,i
do i=1,n
a=b
end do
end subroutine duh
generates
Variable "B" is used before it is defined
from one compiler, and
Name "b" is referenced but not defined.
from another.
However, for instance, if/then/else inside a loop makes it "too hard".
subroutine ex2hard(a,n)
implicit none
real :: a,b
integer :: n,i
do i=1,n
if(n.gt.10)then
b=1.0
a=b
else
a=b
end if
end do
end subroutine ex2hard
generates no warning from either compiler.
The question is, what are other people's compiler experiences with this
problem? One thought that has occurred is that because SOME situations
are detected and warned about, it can lull the user into thinking that
ALL will/should be detected. Then we get (to me unjustified) complaints
about compiler quality. It's almost as if it would be better not to warn
about any, but that's a bit extreme.;-)
On Tuesday, 28 May 2002, at 14:0,
Peter Shenkin <[log in to unmask]> wrote:
> I've also encountered spurious msgs using Purify on Fortran.
> Just thought I'd ask: were the spurious messages all UMRs (Uninitialized
> Memory Reads) or were other spurious messages generated? I've mainly
> had problems with spurious UMRs -- which, by the way, sometimes
> occur for C and C++ programs too, but not nearly as often as with
> Fortran.
So how DO you reliably find uninitialised variables (other than the hard way
- bitter experience)? Or do you consider them "spurious"? :-)
Cheers,
Len
--
[log in to unmask]:+61 3 9669 8109: CSIRO/Bureau of Meteorology
High Performance Computing and Communications Centre
24th floor, 150 Lonsdale St | GPO Box 1289K, Melbourne, VIC 3001 Australia
|