Internal compiler error. BAD sptr in var_refsym


I have created a dummy program and it already generates this error.

[bsc85539@p9login1 test]$ nvc++ main.cpp -gpu=cc70 -o main
NVC+±S-0000-Internal compiler error. BAD sptr in var_refsym 0 (main.cpp: 11)
NVC+±S-0039-Use of undeclared variable (main.cpp: 11)
NVC+±S-0094-Illegal type conversion required (main.cpp: 11)
NVC++/power Linux 22.9-0: compilation completed with severe errors

The code:

#include <stdio.h>

class myClass {
int i = 10;

 void compute() {
	 #pragma omp target parallel for \
	 firstprivate(i) \
	 for (int x = 0; x < i; x++)
	printf("var value = %d\n", i);


int main(void) {

myClass x;

return 0;


I tried without -gpu=cc70 and got the same error. My SDK version is 22.9 but I tried older versions and it didn’t work either. What am I doing wrong?

If you need more information I will provide it to you.

Thank you.

Hi jreinal,

Looks to be a compiler issue when putting the loop bounds variable in a firstprivate clause. Appears to only occur when using the distribute model, but ok when using loop.

I’ve filed a problem report, TPR #33642, and sent it to engineering for review.

The work arounds are to either switch to using “loop”

#pragma omp target teams loop firstprivate(i) default(none)

or remove “firstprivate(i) default(none)”

#pragma omp target teams distribute parallel for

Thanks for the report!

Ok, but now another problem,

the code:

#include <stdio.h>

int main(void) {

int i = 1024; 
	#pragma omp target teams loop firstprivate(i)
	for (int x = 0; x < i; x++) {
		printf("var value = %d\n", x);

return 0;


and I get:

$ nvc++ main.cpp -mp=gpu -o main
nvc+±Warning-CUDA_HOME has been deprecated. Please, use NVHPC_CUDA_HOME instead.
/apps/NVIDIA-HPC-SDK/22.9/Linux_ppc64le/22.9/compilers/share/llvm/bin/llc: error: /apps/NVIDIA-HPC-SDK/22.9/Linux_ppc64le/22.9/compilers/share/llvm/bin/llc: /tmp/nvc++Ue_dkXu4X-pk.ll:104:22: error: use of undefined value ‘%i’
store i32 %6, i32* %i, align 4, !dbg !40

This is only an example, the real code is more complex, so I need firstprivate, private, and so on.

I can’t stop crying.

Thank you!

Related but a different problem that was fixed in our 23.3 release.

Putting a loop bound variable is a firstprivate clause isn’t necessary, so the work around is to remove it.

Ok, thanks.

So, the copy of values are doing by default to pragma section when I use loop?

The last version available in CTE-POWER cluster at BSC is 22.9. I don’t know if they can install the newer version of sdk. But if this the solution is ok.

Thanks again.