Internal Compiler Error using const variable in array def.

Hi guys,

I think there is an error with PGI C compiler because I am not able to use a const sized array without the compiler showing some message concerning the symbol table being referenced.

The error however is misleading because it can jump at any line, although the executable program is behaving correctly.

My code looks like follows:

MPI_Datatype create_custom_type () {
	const int blocks = 2; // a block of floats, followed by a block of ints
	MPI_Datatype types[blocks]={MPI_FLOAT, MPI_INT};
	int lengths[blocks]={2,4};
	MPI_Aint offsets[blocks];
	MPI_Datatype newtype;
	MPI_Aint sizeoffloat;
        MPI_Type_extent(MPI_FLOAT, &sizeoffloat);
	offsets[0] = (MPI_Aint) 0;
	offsets[1] = 2*sizeoffloat;
	MPI_Type_struct(blocks, lengths, offsets, types, &newtype);
	return newtype;
}//create_custom_type()

The error message I get from the compiler is:

PGC-S-0000-Internal compiler error. sym_is_refd: bad sc for    2011

which as you can see is very cryptic. The work around is hardcoding the size of the array when is declared. Still I believe declaring the array size as const should do it.

Anyone else have found this problem when declaring arrays with const sized variables?

Omar V.M.

Hi Omar,

The compiler ICE (TPR#17864) was fixed in the 11.7 compilers. Now your code will produce the following syntax error:

% pgcc -c mpit.c -V11.7 -I/usr/pgi/linux86-64/2011/mpi2/mpich/include/
PGC-S-0169-Variable-sized object, types, cannot be initialized (mpit.c: 5)
PGC-S-0169-Variable-sized object, lengths, cannot be initialized (mpit.c: 6)
PGC/x86-64 Linux 11.7-1: compilation completed with severe errors

Although “blocks” has the “const” qualifier, “types” and “lengths” are still VLAs and can not be initialized. You must either declare these arrays as being fixed size or separate the initialization from the declaration.

Best Regards,
Mat