Repeat count for modern-style initializations

Excellent, we ended up with the following warning in LFortran after a few iterations:

warning: Assuming implicit save attribute for variable declaration
 --> a.f90:2:9
  |
2 | real :: var = 0.0
  |         ^^^^^^^^^ help: add explicit save attribute or parameter attribute or initialize in a separate statement

Which enumerates the same three cases that you mentioned. So this is good.

1 Like

Perhaps the term “initialize” is a little confusing here. In fortran, “initialize” usually means at compile/link time, not at run time. The third alternative in this situation is a run time assignment statement. That is “initialization” in a mathematical or algorithm context, but not in a fortran context.

1 Like

@RonShepard thanks for feedback. How would you formulate it, let’s say: “help: add explicit save attribute or parameter attribute or use a separate runtime assignment statement”?

1 Like

Last time I put SAVE among the specification statements of a subroutine to save everything savable that was declared there, lfortran gave me a lot of warnings I had hoped it wouldn’t, and I had to put things like real,save:: in all the declarations of variables.

Is there a chance that one day we could use something like NO_SAVE where we can now use SAVE if we wanted that effect?

I’ve always wondered why there’s no nosave to disable implicit save.

1 Like

That’s a bug, I just reported it: Implement standalone `save` declaration line · Issue #4544 · lfortran/lfortran · GitHub, it should behave the same no matter where you put the explicit save. Update (12h later): and the bug is fixed. @Harper if you discover any other issue related to this, let us know.

1 Like