https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105538
Bug ID: 105538
Summary: [OpenMP] ALLOCA - MALLOC issue with firstprivate
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: openmp, wrong-code
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
The following fails with host fallback:
character(len=:), allocatable :: x(:)
x = ["abc", "cde"]
!$omp target firstprivate(x)
x = ["abcx", "cdel", "hhgj"]
!$omp end target
end
The problem is:
calculate_firstprivate_requirements (mapnum, hostaddrs, sizes, kinds,
&tgt_align, &tgt_size);
if (tgt_align)
{
char *tgt = gomp_alloca (tgt_size + tgt_align - 1);
copy_firstprivate_data (tgt, mapnum, hostaddrs, sizes, kinds,
tgt_align, tgt_size);
}
firstprivate() now points inside the alloca area and the realloc now fails as
it wasn't malloced.
Question: Is this code valid (I think it is). Is so:
Expected: We possibly need some way to tag memory which should be 'malloc'ed
and not alloca'ed – possibly also with a user-specified allocator (or is this
only permitted for 'private'?) And use that with firstprivate instead.