Go to file
Tobias Burnus a1c4b92e57 OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0
For map(ptr[:0]), the used map kind is GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION
and it is permitted that 'ptr' does not exist. 'ptr' is set to the device
pointee if it exists or to the host value otherwise.

For map(ptr[:3]), the variable is first mapped and then ptr is updated to point
to the just-mapped device data; the attachment uses GOMP_MAP_ATTACH.

For map(ptr[:n]), generates always a GOMP_MAP_ATTACH, but when n == 0, it
was failing with:
   "pointer target not mapped for attach"

The solution is not to fail but first to check whether it was mapped before.
It turned out that for the mapping part, GCC adds a run-time check whether
n == 0 - and uses GOMP_MAP_ZERO_LEN_ARRAY_SECTION for the mapping.
Thus, we just have to check whether there such a mapping for the address
for which the GOMP_MAP_ATTACH. was requested. And, if there was, the
error diagnostic can be skipped.

Unsurprisingly, this issue occurs in real-world code; it was detected in
a code that distributes work via MPI and for some processes, some bounds
ended up to be zero.

libgomp/ChangeLog:

	* target.c (gomp_attach_pointer): Return bool; accept additional
	bool to optionally silence the fatal pointee-not-found error.
	(gomp_map_vars_internal): If the pointee could not be found,
	check whether it was mapped as GOMP_MAP_ZERO_LEN_ARRAY_SECTION.
	* libgomp.h (gomp_attach_pointer): Update prototype.
	* oacc-mem.c (acc_attach_async, goacc_enter_data_internal): Update
	calls.
	* testsuite/libgomp.c/target-map-zero-sized.c: New test.
	* testsuite/libgomp.c/target-map-zero-sized-2.c: New test.
	* testsuite/libgomp.c/target-map-zero-sized-3.c: New test.

(cherry picked from commit 814e29e390)
2025-05-14 20:08:20 +02:00
.github
INSTALL
c++tools
config
contrib
fixincludes
gcc OpenMP: need_device_ptr and need_device_addr support for adjust_args 2025-04-30 17:46:31 +00:00
gnattools
gotools
include OpenMP: 'interop' construct - add ME support + target-independent libgomp 2025-03-22 00:28:19 +01:00
libada
libatomic
libbacktrace
libcc1
libcody
libcpp Daily bump. 2025-03-28 00:23:52 +00:00
libdecnumber
libffi
libgcc GCN, nvptx offloading: Host/device compatibility: Itanium C++ ABI, DSO Object Destruction API [PR119853, PR119854] 2025-04-25 18:55:33 +02:00
libgfortran Merge remote-tracking branch 'origin/releases/gcc-14' into devel/omp/gcc-14 2025-04-08 23:51:05 +02:00
libgm2
libgo
libgomp OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0 2025-05-14 20:08:20 +02:00
libgrust
libiberty
libitm
libobjc
libphobos Daily bump. 2025-03-22 00:27:43 +01:00
libquadmath LoongArch: Add LoongArch architecture detection to __float128 support in libgfortran and libquadmath [PR119408]. 2025-04-08 09:19:14 +08:00
libsanitizer
libssp
libstdc++-v3 GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645] 2025-04-17 09:35:51 +02:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog
ChangeLog.jit
ChangeLog.omp GCN, nvptx: Don't default-disable libstdc++ build 2025-03-19 10:01:51 +01:00
ChangeLog.tree-ssa
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
README
SECURITY.txt
ar-lib
compile
config-ml.in
config.guess
config.rpath
config.sub
configure GCN, nvptx: Don't default-disable libstdc++ build 2025-03-19 10:01:51 +01:00
configure.ac GCN, nvptx: Don't default-disable libstdc++ build 2025-03-19 10:01:51 +01:00
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.