Hi!
I have that piece of code at the bottom. When compiling with nvcc as a .cu file, compiler warnings are issued. When compiled as .cpp file, no warnings occur. Two things bother me:
- I have a static_assert in the class which shows that the type is actually POD (see program output). So why would it warn me that is is non-POD?
- g++ doesn't issue that warning. Also, I could disable it with '-Wno-invalid-offsetof'. However, nvcc does not accept that flag. What can I use with nvcc to get rid of the (unnecessary?) warnings?
nvcc is V6.5.12. Output:
$ nvcc -std=c++11 offsetof_error.cu -o app
offsetof_error.cu(30): warning: offsetof applied to non-POD types is nonstandard
offsetof_error.cu(30): warning: offsetof applied to non-POD types is nonstandard
$ ./app
4data is pod? 1
Offset of head is: 0
$ nvcc -std=c++11 offsetof_error.cpp -o app
$ ./app
4data is pod? 1
Offset of head is: 0
#include <iostream>
#include <typeinfo>
#include <type_traits>
#include <cstddef>
using namespace std;
template <typename T> struct queue_t
{
T *head;
T *tail;
};
struct data
{
int foo;
};
template<typename T> class myclass
{
static_assert(std::is_pod<T>::value, "Queue Payload must be POD!");
static_assert(std::is_pod< queue_t<T> >::value, "Queue Payload must be POD!");
public:
myclass()
{
cout << typeid(T).name() << " is pod? " << is_pod< queue_t<T> >::value << endl;
cout << "Offset of head is: " << offsetof(queue_t<T>, head) << endl;
}
};
int main()
{
myclass<data> test;
return 0;
}
Thanks for your help,
nargin