Skip to content

[OpenMP] Static class members not implicitly captured from derived classes #93869

@jhuber6

Description

@jhuber6

When a derived class is present in a target region it will try to automatically declare members on the device. This is not correctly handled when done through a derived class that references the parent. See the example on godbolt https://godbolt.org/z/zvG5nr6KW and below.

class C {
public:
  C() { asm volatile(""); }
  virtual ~C() { asm volatile(""); }
  static int x;
};

int C::x = 0;
class D : public C {
public:
  D() { x = 1; }
};

void foo() {
#pragma omp target
  {
    D d;
  }
}

Here, the variable x is not captured on the device and thus shows up as an extern variable. This is then never resolved and fails at link time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions