[proxy] github.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

Conversation

Copy link
Contributor

This PR fixes an instance of invalid Fortran code where an allocatable character component is referenced while unallocated during string concatenation. For eg.
target%compile_flags = target%compile_flags // ' ' // compile_flags

If target%compile_flags is unallocated, this code is not standard-conforming. Although automatic allocation on assignment is permitted for allocatable variables on the left-hand side, the right-hand side expression must be fully evaluated before allocation occurs.

Referencing an unallocated allocatable variable during expression evaluation is prohibited by the Fortran standard:
5.4.10 p2: “An unallocated allocatable variable shall not be referenced or defined.”
10.2.1.1: the right-hand side of an intrinsic assignment is evaluated prior to any automatic allocation.
9.7.1.3: automatic allocation applies only after expression evaluation.
10.1.5.3: the // operator requires both operands to be referenced to obtain their values.

Copy link
Member

certik commented Jan 27, 2026

@perazz, can you please review this PR?

certik requested a review from perazz January 27, 2026 23:38
Copy link
Member

perazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sync this branch with main

Copy link
Contributor Author

Rebased my branch with main

perazz merged commit d0f8995 into fortran-lang:main Jan 28, 2026
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants