https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121353

            Bug ID: 121353
           Summary: [OpenMP] 'declare mapper' - ICE on invalid code,
                    rejected in 'struct'
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code, openmp, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

See also OpenMP Issue #4539 for putting the declare into a C++ struct/class,
which is required to avoid 'private' and 'template' issues.

The following applies likewise to C and C++ - both give the ICE in the same
function and both reject the 'declare mapper' inside 'struct'.


* * *

#include <cstddef>

struct RGB { double r, g, b; };
struct RGB_vector
{
// Fails as follows - also when moved down just before the '};'.
//   error: ‘RGB_vector RGB_vector::v’ has incomplete type
//   error: storage size of ‘#pragma omp declare mapper (RGB_vector)’ isn’t
known
//#pragma omp declare mapper (RGB_vector v) map(v, v.v[:v.sz])

  size_t sz;
  RGB *v;
};

// Works:
// #pragma omp declare mapper (RGB_vector v) map(v, v.v[:v.sz])

// ICE (note the 'v[...]' instead of 'v.v[...]'):
//   in omp_instantiate_mapper, at c-family/c-omp.cc:4440
 #pragma omp declare mapper (RGB_vector v) map(v, v[:v.sz])

int main()
{
  RGB_vector rgbv;
//  rgbv.sz = 123;
//  rgbv.v = new RGB[rgbv.sz];
// or: rgbv.v = (RGB*) __builtin_malloc (rgbv.sz * sizeof(RGB));
  #pragma omp target map(rgbv)
    rgbv.v[122] = { 1,2,3};
}

Reply via email to