I suspect this is a nvcc bug. Consider the following:
#include <cstdio>
struct A {
static constexpr std::size_t rank = 3;
static constexpr std::size_t rank_dynamic = 2;
};
struct B {
static constexpr std::size_t rank = 2;
static constexpr std::size_t rank_dynamic = 1;
};
struct C {
template < class T >
static constexpr std::size_t rank = T::rank;
template < class T >
static constexpr std::size_t rank_dynamic = T::rank_dynamic;
template < class T >
static constexpr std::size_t rankStatic = rank<T> - rank_dynamic<T>;
};
template < class T >
constexpr std::size_t C::rank;
template < class T >
constexpr std::size_t C::rank_dynamic;
template < class T >
constexpr std::size_t C::rankStatic;
int main(int argc, char* argv[]) {
}
This compiles and runs fine with gcc or clang that supports c++14. But nvcc test.cpp -o test -x cu -std=c++14 triggers:
../test.cpp(21): internal error: assertion failed at: "/dvs/p4/build/sw/rel/gpu_drv/r396/r396_00/drivers/compiler/edg/EDG_4.14/src/class_decl.c", line 3919
1 catastrophic error detected in the compilation of "/tmp/tmpxft_000204b9_00000000-4_test.cpp4.ii".
Compilation aborted.
nvcc error : 'cudafe++' died due to signal 6
nvcc error : 'cudafe++' core dumped
This is legit non-odr use of variable template as static member of a class. I’d suggest add support for this feature.