You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lfortran ICE on accessing parent component in a dummy argument #10978
I just pushed a commit to Formal to work around an lfortran internal compiler error (ICE) . As shown below, the workaround is trivial so this issue not important to me. I'm just reporting it so you're aware.
This is fixed on current main (and in releases since 0.64.0) by commit 71e4f6d "Fix parent-type-name component access crash" (PR #12116, regression test integration_tests/derived_types_149.f90).
Here is a small example with the pattern from the issue: accessing a component through the parent-type name (self%parent_t%values_) of a class() dummy inside a submodule procedure.
module m
implicit none
type :: parent_t
double precision, allocatable :: values_(:)
integer:: order_ =0
end type
type, extends(parent_t) :: child_t
integer:: extra_ =0
end type
interface
pure module function child_over_integer(self, n) result(ratio)
class(child_t), intent(in) :: self
integer, intent(in) :: n
type(child_t) :: ratio
end function
end interface
end module
submodule(m) m_s
implicit nonecontains
module procedure child_over_integer
ratio%parent_t = parent_t(self%parent_t%values_/n, order_=self%order_)
ratio%extra_ = self%extra_
end procedure
end submodule
program ex10978
use m
implicit none
type(child_t) :: c, r
c%parent_t = parent_t([2d0, 4d0, 6d0], order_=2)
c%extra_ =7
r = child_over_integer(c, 2)
print*, r%values_, r%order_, r%extra_
if (any(r%values_ /= [1d0, 2d0, 3d0])) error stopif (r%order_ /=2.or. r%extra_ /=7) error stopend program
I also checked Formal itself with current main, both before the workaround (420c46f) and at the workaround commit (7bb94ce). Both build, and fpm test --compiler lfortran --flag "--cpp --realloc-lhs-arrays --separate-compilation" passes. Current Formal main passes as well.
About the earlier comment that the workaround still failed in the LFortran container: I could not reproduce that with 0.61, 0.63 or current main. The container image was most likely older than the fix. If you still see a failure with a current ghcr.io/lfortran/lfortran:latest, please post the full lfortran --version, the exact command line, and the error output, and we'll reopen.
Activity
rouson commentedon Apr 6, 2026
Correction: although the above workaround resolves this issue in the checked configurations below, it fails on the unchecked one.
lfortran0.60.0-421-ge2c448c79 on a macOS ARM systemlfortran0.6.1 on Ubuntu 24.04 in CI on Formal PR 18Is this a regression or is it possible that the container has an
lfortranversion older than0.6.1?certik commentedon Sep 27, 2026
This is fixed on current
main(and in releases since 0.64.0) by commit 71e4f6d "Fix parent-type-name component access crash" (PR #12116, regression testintegration_tests/derived_types_149.f90).Here is a small example with the pattern from the issue: accessing a component through the parent-type name (
self%parent_t%values_) of aclass()dummy inside a submodule procedure.With LFortran 0.63.0 the compiler segfaults:
With current
main(0.66.0-445-g611fbfe8d):This matches gfortran.
I also checked Formal itself with current
main, both before the workaround (420c46f) and at the workaround commit (7bb94ce). Both build, andfpm test --compiler lfortran --flag "--cpp --realloc-lhs-arrays --separate-compilation"passes. Current Formalmainpasses as well.About the earlier comment that the workaround still failed in the LFortran container: I could not reproduce that with 0.61, 0.63 or current
main. The container image was most likely older than the fix. If you still see a failure with a currentghcr.io/lfortran/lfortran:latest, please post the fulllfortran --version, the exact command line, and the error output, and we'll reopen.Generated by Claude Code
certik commentedon Sep 27, 2026
It looks like this is now fixed.