Re: Uninitialized variable detection in Fortran

Daniel Feenberg via Valgrind-users <[email protected]> Sat, 26 Oct 2024 07:36:05 -0400 (EDT)
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>

On Fri, 25 Oct 2024, Paul Floyd via Valgrind-users wrote:

>
>
> On 24-10-24 14:33, Daniel Feenberg via Valgrind-users wrote:

...

>>  origins" would do that. Is there an option or other way to ask Valgrind to
>>  be a little stricter, and flag the use of an unidentified variable in an
>>  assignment, not just in a condition?
>
> Uninitialized read errors are not triggered simply by reading uninitialized 
> memory. There are many cases where uninitialized memory gets copied in a 
> harmless manner. That would be overwhelming. Instead we only trigger errors

This is very disappointing. Such moves may be frequent in other languages, 
but I don't see it happening to much in my Fortran 95 code. I suppose if 
subroutine arguments are copy-in/copy-out, that would be a source of 
spurious messages, as could code in libgfortran,but Valgrind typically has 
the source and could drop those messages.

I did eventually locate the problem in my code, by adding a large number 
of write statements scattered thoughout the code, and noting the earliest 
one to trigger Valgrind.

Daniel Feenberg