Issue 178813
Summary [Flang] assignment to a procedure pointer within structure constructors does not work correctly
Labels flang
Assignees
Reporter 3776-u2
    ```
Version of flang : 23.0.0git (eb773961aac45593ce126ed258d82c3c3abbaa93)
Target: aarch64-unknown-linux-gnu
```

As demonstrated in the sample.f90 code provided below, test1 behaves as expected with regular member assignment. However, the assignment statement involving a procedure pointer in a structure constructor within test2 causes a segmentation fault at runtime.

Reference:  
Fortran 2023 Standard  
7.5.10 Construction of derived-type values

sample.f90
``` fortran
  call test1
  call test2
end

subroutine test1
  type ty1
     integer :: i1 = 0
 integer :: i2 = 2
  end type ty1

  type (ty1) ::str1
  str1 = ty1(i1=1)
  print *, str1
end subroutine test1

subroutine test2
 interface
     subroutine sub()
     end subroutine sub
  end interface

  type ty2
     procedure(sub) ,nopass,pointer ::p1 => null()
 procedure(sub) ,nopass,pointer ::p2 => sub
  end type ty2

  type (ty2) ::str1
  str1 = ty2(p1= sub)
  call str1%p2
end subroutine test2

subroutine sub()
print *, 'PASS'
end subroutine

```

``` text
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang sample.f90
$ ./a.out
 1 2
Segmentation fault (core dumped)
$
$ gfortran sample.f90
$ ./a.out
           1           2
 PASS
$ ifx sample.f90
$ ./a.out
           1           2
 PASS
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to