Reporting uninitialised variables

Arjen Markus arjen.markus895@gmail.com
Tue Jun 9 06:45:00 GMT 2009


2009/6/8 Thomas Koenig <tkoenig@netcologne.de>:
> On Mon, 2009-06-08 at 11:12 +0200, Arjen Markus wrote:
>> subroutine chk
>>     implicit none
>>
>>     real :: x, y, z
>>     logical :: compare
>>
>>     !
>>     ! use uninitialised variable
>>     !
>>     write(*,*) z
>
> This is an effect of PR 20165.  Currently, we pass pointers to variables
> for calls to the functions that make up the write statement.  The middle
> end then assumes that the value could be set by the write.
>
> I haven't thought about this for a while.  Is this something that we
> want to change with the ABI cleanup?
>
>

Well, that indeed explains why there is no warning. If I change the statement
"write(*,*) z" to "x = z", I do get the warning indeed.

But if I _add_ the following statements:

   x = z
   z = 1

before the original write statement, there is no message.

Actually, moving the write statement to the very end of the subroutine
causes the warning to disappear!

So the presence of the write statement influences the capability to detect
this error.

Regards,

Arjen



More information about the Fortran mailing list