Thanks for the report. I added TPR#27435 to track this issue.
The problem here is that since “n2” isn’t used anywhere else except as the loop bounds to a private clause, the reference is getting deleted. I’ve seen similar issues in the past but it looks like we missed this case. The same code works when targeting Tesla or when used in a copy clause.
The work around would be to use “n” in place of “n2”, or reference “n2” someplace in the body of the loop. Something like:
void func(float* b, unsigned n) {
unsigned n2 = n;
#pragma acc parallel loop independent private(b[0:n2])
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n2; ++j) {
}
}
}