An undeclared variable in a template function results in a crash of the compiler.
C:\CUDA\bin>nvcc --version
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2007 NVIDIA Corporation
Built on Wed_Jul_16_12:57:50_PDT_2008
Cuda compilation tools, release 2.0, V0.2.1221
1>bug.cu(20): internal error: assertion failed: gen_expr: bad expr node kind (D:/Bld/rel/gpgpu/toolkit/r2.0/compiler/edg/EDG_3.9/src/cp_gen_be.c, line 9509)
1>1 catastrophic error detected in the compilation of “c:\tmp\junk/tmpxft_00000d2c_00000000-6_bug.cpp1.ii”.
1>Compilation aborted.
1>This application has requested the Runtime to terminate it in an unusual way.
1>Please contact the application’s support team for more information.
#include <cutil.h>
#include <cuda.h>
template <typename ElementType>
class CudaDoubleBuffer {
private:
ElementType *DeviceBuffer2;
public:
ElementType *
GetDeviceOutputBuffer(
)
{
if (!DeviceBuffer2) {
cudaMalloc((void **)&DeviceBuffer2,
Bytecount);
}
return DeviceBuffer2;
}
};
Note that changing:
template <typename ElementType>
to
typedef void *ElementType;
results in the correct warning for an undeclared identifier. Adding the missing declaration allows compilation to complete.