[Bug libgomp/106643] [gfortran + OpenACC] Allocate in module causes refcount error
hberre3 at gatech dot edu
gcc-bugzilla@gcc.gnu.org
Wed Aug 31 02:16:24 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106643
--- Comment #1 from Henry Le Berre <hberre3 at gatech dot edu> ---
Here is a more minimal version:
m_mod.f90:
```fortran
module m_mod
real(kind(0d0)),allocatable, dimension(:) :: arrs
!$acc declare create(arrs)
contains
subroutine s_mod_init()
allocate(arrs(10))
!$acc enter data create(arrs(10))
!$acc update device(arrs(10))
!$acc exit data delete(arrs)
end subroutine s_mod_init
end module m_mod
```
p_main.f90:
```
program p_main
use m_mod
call s_mod_init()
end program p_main
```
Here is a C version that runs without issue:
m_mod.c:
```
#include <stdio.h>
#include <stdlib.h>
double* arrs;
#pragma acc declare create(arrs)
void m_mod_init() {
arrs = (double*)malloc(10*sizeof(double));
#pragma acc enter data create(arrs[0:9])
#pragma acc update device(arrs[0:9])
#pragma acc exit data delete(arrs)
}
```
p_main.c:
```
extern void m_mod_init();
int main() {
m_mod_init();
}
```
More information about the Gcc-bugs
mailing list