<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/93869>93869</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] Static class members not implicitly captured from derived classes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jhuber6
</td>
</tr>
</table>
<pre>
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/qazMKTEqr and below.
```c++
class C {
public:
C() { asm volatile(""); }
virtual ~C() { asm volatile(""); }
static int x;
};
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEGL8zYQ_TXyZfiMLcdxfPBhd91QKB8t7ELPsjSxtZUlrzR2kj30txc52eymC4WCINGM5r0nzRuLEHRvERtWPrKyTcRMg_PN6zB36LdJ59S5-XNACwIUer2gAmlECKADTB4DWgIdsyR8jwQee-0saIKjNgbIn4EciJncKEhLYcwZFEojPMKIY4c-gLNAA4LCRUtM4WXQK7x1BNJ5j5LMGQZhlUEFxyhGOYtAg3dzP3xTBjSIKOSAHq3EsIJPwqOlFJ4R1z2exDgZjNy9U50zBAPRFFjxwPie8f01mjrfM75_Z3z_Jt5__vbyy5sHYRV0aNwxZVnLsge2zS5LMv4Y1xq9qHkCVl0D09wZLSPDugV4YnzHeB1PgAgjLM4I0gbXMF9XzYpHYFV7LVm0p1kY-Pv_l0Kg2AHQluDEiqummL_9_yK7BVY8wEXxf96h_SLkBKxoIb_j_U6wOK3g4Nxn4TXLi8mLfhTgxunqpw-W2yEAgBbUDRLume7bcdn-ih4Zf1rbvgivRWcQ2DY7sW1285mYaPao7r24NpqGOUAY3DHAPIEIIGysxhOhtxHiA_PTuRQ9anFBDx6DM9GbEeogtAkgCIy2fwHpEdNENYWqi1ok2ORVXmV1nfMiGZqcV1LWvJNZJcttV0heymyTy67cyF1V14lueMY3WVlkeV3uNkXK81LVmdyhUnWlSs42GY5Cm9SYZYw-TnQIMzZ1sdvWiREdmrCOPecWj7Amo3HKNvFNrPnRzX1gm8zoQOEThTSZ9Xvx-4T25x-sbOH5Yq2LdT7GOr6rHiejpY4DfHvig3fj_chiSGZvmn8NoKZh7lLpRsb3kfz682Py7hUlMb5fJQfG95crLQ3_JwAA__-mZHtM">