Skip to content

Allocatable automatic deallocation #62354

Closed
@kiranchandramohan

Description

@kiranchandramohan

See Fortran 2018 standard: "9.7.3.2 Deallocation of allocatable variables" point 2:

When the execution of a procedure is terminated by execution of a RETURN or END statement, an unsaved
allocatable local variable of the procedure retains its allocation and definition status if it is a function result or a
subobject thereof; otherwise, if it is allocated it will be deallocated.

This is currently not implemented and does not have a TODO. This causes:

  • memory leaks in program relying on this feature.
  • lack of type finalization for allocatable that require it.

This should be implemented in ConvertVariable.cpp here:

, in a similar way to what is done for local objects that require finalization (see the code below if needEndFinalization), except deallocation must be added to the function context cleanups.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:ir

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions