"Unexpected name table type" error and ordering of C++ class members

Hello there,

I encountered something rather odd while experimenting with C++ inheritance and OpenACC.

The following code compiles well with “pgc++ -acc -ta=nvidia -Minfo=accel” and produces correct results.

#include <iostream>
#include "openacc.h"
#include "accel.h"

class Base1 {
        protected:
          int len1;
          int* varbase1;
        Base1()
        {
          len1 = 2;
          varbase1 = new int[len1];
          for(int i=0; i<len1; i++) varbase1[i]=1;
        }
};

class Level2: public Base1 {
  public:
    Level2()
      {
        #pragma acc enter data copyin(this)
        #pragma acc enter data create(varbase1[0:len1] )
      }
    void printAll()
      {
        std::cout << "==========printAll================" << std::endl;
        for(int i=0; i<len1; i++) std::cout << "Base1: element" << i <<"=" << varbase1[i] << std::endl;
      }
#pragma acc routine seq
    void updatebase()
      {
        for(int i=0; i<len1; i++) varbase1[i] = i*2;
      };
    void updatehost()
      {
        #pragma acc update host(varbase1[0:len1]) 
      };
 };
 
 int main () {
        Level2 obj_level2;
        obj_level2.printAll();

        #pragma acc serial
        {
        obj_level2.updatebase();
        }

        obj_level2.updatehost();
        obj_level2.printAll();

  return 0;
}

However, compilation would fail if “int* varbase1” is placed first in the Base1 class definition, as follows:

class Base1 {
        protected:
        int* varbase1;
        int len1;
        Base1()
        {
          len1 = 2;
          varbase1 = new int[len1];
          for(int i=0; i<len1; i++) varbase1[i]=1;
        }
};

and the compilation error message is:

[my login]$ pgc++ -acc -ta=nvidia -Minfo=accel inheritance.C
main:
45, Accelerator serial kernel generated
Generating Tesla code
Generating implicit copy(obj_level2)
PGCC-F-0155-Compiler failed to translate accelerator region (see -Minfo messages): Unexpected name table type (inheritance.C: 23)
PGCC/x86 Linux 18.10-1: compilation aborted

and line 23 corresponds to the “}” under #pragma acc enter data create(varbase1[0:len1] )

The version of the PGI compiler used is:
[my login]$ pgcc --version

pgcc 18.10-1 64-bit target on x86-64 Linux -tp skylake
PGI Compilers and Tools
Copyright © 2018, NVIDIA CORPORATION. All rights reserved.

Is this behavior expected?

Hi,

This is definitely not expected behavior. I don’t think the ordering of protected (or public/private members) should make a difference. I think this is a bug. I’ve filed TPR #27076 for someone to investigate.

Thanks, aglobus. I will stay tuned.