Hello,
Through debugging a larger codebase, I have discovered an issue which causes nvcc version 11.2 to encounter a segmentation fault while compiling. nvcc version 10.0 can compile the code successfully without any issues.
main.cu:
#include <iostream>
#include "templateHeader.h"
int main() {
std::cout << "Test Program" << std::endl;
return 0;
}
templateHeader.h:
#ifndef TEMPLATE_HEADER
#define TEMPLATE_HEADER
template<int offset>
class ParentTemplateClass {
static constexpr int parentTestStaticInt = 0;
};
template<int offset>
class ChildTemplateClass : public ParentTemplateClass<offset+1> {
public:
static constexpr int childTestStaticInt = 1+ParentTemplateClass<offset+ChildTemplateClass::childTestStaticInt>::parentTestStaticInt;
};
#endif
The problem seems to be that childTestStaticInt is defined recursively in terms of itself. Obviously, this doesn’t really make any sense. However, I believe that the compiler should not segfault as a result.