Skip to content

MRE for pot3d --fast compilation #6611

@Pranavchiku

Description

@Pranavchiku
module xx
    type :: rp1d
        real, dimension(:), pointer :: f
    end type

    type :: sds
        integer, dimension(3) :: dims
        type(rp1d), dimension(3) :: scales
        real, dimension(:), pointer :: f
    end type
end module
subroutine sub()
    use xx
    real, dimension(:), pointer :: x
    call sub_to_allocate(x)
    print *, "x in sub = ", x
    deallocate(x)
    contains
    subroutine sub_to_allocate(x)
        use xx
        real, dimension(:), pointer :: x
        type(sds) :: s
        allocate(s%scales(1)%f(2))
        x => s%scales(1)%f
        x(1) = 2.0
        x(2) = 1.0
        print *, "x = ", x
    end subroutine
end subroutine
program derived_types_43
    implicit none
    call sub()
end program
% lfortran a.f90           
x = 
2.00000000e+00
1.00000000e+00

x in sub = 

% lfortran a.f90 --fast
x = 
2.00000000e+00
1.00000000e+00

x in sub = 

a.out(11318,0x1ec134c00) malloc: *** error for object 0x10028bef7: pointer being freed was not allocated
a.out(11318,0x1ec134c00) malloc: *** set a breakpoint in malloc_error_break to debug
% gfortran a.f90 && ./a.out
 x =    2.00000000       1.00000000    
 x in sub =    2.00000000       1.00000000    
% gfortran a.f90 -o3 && ./a.out            
 x =    2.00000000       1.00000000    
 x in sub =    2.00000000       1.00000000    

Metadata

Metadata

Assignees

No one assigned

    Labels

    --fastIssues related to the `--fast` compiler optionPOT3DIssues or pull requests related to compiling `predsci/POT3D`bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions