https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95506
Bug ID: 95506 Summary: [OpenMP] omp target – private clause and allocatables – unallocated or reallocation Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: openmp Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- Found when playing around with PR95499 – which is about ICEs. The following program fails at run time – the actual argument is not allocated – hence, 'str = "a"' will allocate str on assignment if (*str != 0B) goto L.1; *str = (character(kind=1)[1:*_str] *) __builtin_malloc (1); goto L.2; However, if '*str == NULL' the code crashes, likewise, if the 'str' is allocated to a different length (e.g. 'my_str = "ab"' + 'str = "a"' + change 'len=5' to 'len=:'). As 'str' is private, I think the (re)allocation of 'str' should be fine, shouldn't it? program main implicit none character(len=5), allocatable :: my_str ! my_str = "b" ! << commented, i.e. unallocated call bar_str(my_str) contains subroutine bar_str(str) integer :: i character(len=5), allocatable :: str !$omp target private(str) str = "a" print *, str !$omp end target end end