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 Minor formatting fix for newly-added file from previous commit 2023-11-01 19:28:56 -04:00
INSTALL
c++tools Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
config Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
contrib Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
fixincludes Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
gcc OpenMP: need_device_ptr and need_device_addr support for adjust_args 2025-04-30 17:46:31 +00:00
gnattools Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
gotools Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
include OpenMP: 'interop' construct - add ME support + target-independent libgomp 2025-03-22 00:28:19 +01:00
libada Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libatomic Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libbacktrace Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libcc1 Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libcody Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libcpp Daily bump. 2025-03-28 00:23:52 +00:00
libdecnumber Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libffi Merge branch 'releases/gcc-14' into devel/omp/gcc-14 2024-08-01 11:09:11 +02:00
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 Daily bump. 2024-11-21 00:26:12 +00:00
libgo libgo: bump libgo version for GCC 14 release 2024-02-05 11:28:30 -08:00
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 Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libiberty Daily bump. 2024-09-13 00:21:45 +00:00
libitm Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libobjc Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
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 Daily bump. 2024-09-06 00:22:34 +00:00
libssp Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
libstdc++-v3 GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645] 2025-04-17 09:35:51 +02:00
libvtv Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
lto-plugin Daily bump. 2024-09-05 00:22:17 +00:00
maintainer-scripts Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
zlib Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
.dir-locals.el dir-locals: Use https for bug references 2021-07-20 11:40:34 +01:00
.gitattributes
.gitignore *: add modern gettext 2023-11-14 00:47:11 +01:00
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
ChangeLog.jit
ChangeLog.omp GCN, nvptx: Don't default-disable libstdc++ build 2025-03-19 10:01:51 +01:00
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Update my email address 2024-04-04 16:39:52 +02:00
Makefile.def Disable libstdc++ dependency for libffi 2024-05-07 11:49:57 +02:00
Makefile.in Disable libstdc++ dependency for libffi 2024-05-07 11:49:57 +02:00
Makefile.tpl Fix up postboot dependencies [PR106472] 2024-04-02 13:40:27 +02:00
README
SECURITY.txt SECURITY.txt: Drop "exploitable" in reference to hardening issues 2024-01-09 10:49:01 -05:00
ar-lib
compile
config-ml.in LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
config.guess
config.rpath
config.sub config.sub: change mode to 755. 2021-12-21 09:10:57 +01:00
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 Build: fix error in fixinclude configure 2023-11-22 11:54:33 +01:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4 Sync from git Libtool and regenerate. 2009-12-05 17:18:53 +00:00
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.