[gcc/devel/omp/gcc-16] libgomp/oacc-mem: add missing assert to goacc_enter_datum

Sandra Loosemore via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:f45761ab091944e9da6736d807e3caf7ea6f6ca9

commit f45761ab091944e9da6736d807e3caf7ea6f6ca9
Author: Arsen Arsenović <[email protected]>
Date:   Fri Apr 24 12:58:49 2026 +0000

    libgomp/oacc-mem: add missing assert to goacc_enter_datum
    
    A bug I accidentally introduced made it so that new variables are
    allocated with some room to spare before them, and ergo, that tgt_offset
    != 0, leading to tests failing in what looked like a strange way.  Turns
    out, goacc_enter_datum was failing to validate its assumption that
    tgt_offset == 0.  This patch adds that assert.
    
    libgomp/ChangeLog:
    
            * oacc-mem.c (goacc_enter_datum): Assert that tgt_offset of the
            newly-mapped variable is zero.
    
    (cherry picked from commit 059f19c7957fd5c0e72b5202f2347419ad6d2a72)

Diff:
---
 libgomp/oacc-mem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index 5601daf13957..f9ceb094d156 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -593,6 +593,9 @@ goacc_enter_datum (void **hostaddrs, size_t *sizes, void *kinds, int async)
       assert (n);
       assert (n->refcount == 1);
       assert (n->dynamic_refcount == 0);
+      assert (/* This is only reached if we're mapping a new, singular
+		 variable, and so, its offset ought to be zero.  */
+	      n->tgt_offset == 0);
       n->dynamic_refcount++;
 
       d = (void *) tgt->tgt_start;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.