I am writing a template function * similar to the following:
template <typename T, bool v>
void foo(T t1) {
if (v) {
int i = bar();
return;
}
else {
}
}
When I compile this and foocreate using vset to false, the compiler says:
warning: dynamic initialization in unreachable code
Now the code is unreachable due to the template argument; and that should be perfectly acceptable. How can I avoid or suppress this warning? I would rather not suppress such warnings at all.
Notes:
- I would prefer not to specialize differently for true and false, since there is a common code there, and I do not want to duplicate, as well as artificially create another function.
- CUDA NVCC. , , , .