fix: handle indices correctly in cshift intrinsic #6372
Merged
Conversation
Contributor
Author
|
With this, the error is now different: $ cat lf.sh
lfortran a.f90 --dump-all-passes-fortran --apply-fortran-mangling
gfortran -fcheck=all -g -c pass_fortran_31_insert_deallocate.f90
gfortran pass_fortran_31_insert_deallocate.o -o pass_fortran_31_insert_deallocate
./pass_fortran_31_insert_deallocate
$ sh lf.sh
At line 10 of file pass_fortran_31_insert_deallocate.f90
Fortran runtime error: Attempt to DEALLOCATE unallocated 'r_g'
Error termination. Backtrace:
#0 0x7a2747823960 in ???
#1 0x7a27478244d9 in ???
#2 0x7a2747824ad6 in ???
#3 0x5953aa69777e in pot3d
at /home/harshita/Desktop/lfortran/pass_fortran_31_insert_deallocate.f90:10
#4 0x5953aa697a2a in main
at /home/harshita/Desktop/lfortran/pass_fortran_31_insert_deallocate.f90:10which is because there are two consecutive deallocate statements after the insert_deallocate pass ! Fortran code after applying the pass: insert_deallocate
program pot3d
implicit none
integer(4), parameter :: dp = 8
integer(4), save :: n = 3
real(8), dimension(:), allocatable :: r_g
allocate(r_g(n))
call genmesh(n, r_g)
! here
deallocate(r_g)
deallocate(r_g) ! Implicit deallocate
contains
... |
gxyd
reviewed
Feb 20, 2025
gxyd
left a comment
Contributor
There was a problem hiding this comment.
The change looks good to me. I'm still thinking if there is a way to add a test case here.
Also, I checked it locally on my machine and this change allows us to remove the workaround from POT3D
certik
approved these changes
Feb 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
towards: #6370
Also addresses: #6352 (comment)