Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialisation in declaration should require explicit save #60

Open
ZedThree opened this issue Oct 3, 2024 · 1 comment
Open

Initialisation in declaration should require explicit save #60

ZedThree opened this issue Oct 3, 2024 · 1 comment
Labels
enhancement New feature or request rule A new rule for the linter

Comments

@ZedThree
Copy link
Member

ZedThree commented Oct 3, 2024

Initialisation in declarations gets an implicit save, meaning the initialisation is not done on subsequent entry into the routine.

Bad:

subroutine foo()
  integer :: bar = 1
end subroutine

Good:

subroutine foo()
  integer, save :: bar = 1
end subroutine

Also good:

subroutine foo()
  integer :: bar
  bar = 1
end subroutine
@ZedThree ZedThree added enhancement New feature or request rule A new rule for the linter labels Oct 3, 2024
@LiamPattinson
Copy link
Collaborator

Glad you've raised this, because I wasn't aware of this behaviour. Might have to go back to edit some old code I wrote...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rule A new rule for the linter
Projects
None yet
Development

No branches or pull requests

2 participants