Silverfrost Forums

Welcome to our forums

8.20 and /Zeroize

22 Dec 2017 9:22 #21030

ok, so, just for clarification..

program test
    write(*,*) 'i=',i
end

under 8.2/64 reports an undefined variable.

but

program test
call test1
end

subroutine test1 
    write(*,*) 'i=',i
end

reports 0.

One thing i notice is that under 8.20/64 a console application is generated but under 8.1/32, a white window is created with the result. is there a switch for this (i'd prefer the white window method).

both compilation scripts have '/windows' specified.

K

22 Dec 2017 10:07 #21031

Quoted from KennyT

One thing i notice is that under 8.20/64 a console application is generated but under 8.1/32, a white window is created with the result. is there a switch for this (i'd prefer the white window method).

both compilation scripts have '/windows' specified.

K

ok, i found the windows SLINK64 command (RTFM!), although i note that it's not reported by SLINK64/help as being there as an option.

K

22 Dec 2017 3:13 #21032

Kenny

The whole concept relates primarily to variables that are given the SAVE attribute. As Eddie has noted, this extends to the COMMON BLOCK. So your tests should use SAVE either in the code or on the FTN95 command line.

22 Dec 2017 3:18 #21033

so why did 'I' get set to zero in the subroutine, when there wasn't a SAVE statement?

not that i'm complaining, just interested!

K

22 Dec 2017 3:48 #21034

I could work through the compilation etc. to get a definitive answer but the short answer is that it could be a random zero or maybe not. The important thing is to know is when you can be confident that a variable is preset to zero.

My personal recommendation would be to avoid all dependence on 'zeroise', to test using /UNDEF and make sure when testing that all routes through the code are traversed.

26 Dec 2017 2:55 #21038

... or put another way, not initialising all variables is bad coding practice and not portable.

Sorry to be a grouch, but I never assume zero for uninitialized variables. If I have not initialised a variable then it is a mistake that needs fixing.

If you have an accumulator that is not initialised, what do you expect to happen the second time you use the routine ?

26 Dec 2017 9:45 #21039

I agree with John C here, and for me (for quite a long time) the need was to find the quickest and best way to initialise large blocks of data.It seems to be extremely fast now. Assuming things start out as being zeroed will eventually come back and bite you.

Eddie

Please login to reply.