Inheritance bug?

i know that C++ doens’t fully support on host yet, but i will report about strange compiler behaviour.

#ifndef __CUDACC__

	#define __align__(N) __declspec(align(N))

#endif

#define SSE_ALIGN_BOUNDARY 16

#define SSE_ALIGNED __align__(SSE_ALIGN_BOUNDARY)

struct SSE_ALIGNED SSE_Aligned_Object {/*some code*/}

struct vec4f : public SSE_Aligned_Object {/*some code*/}

struct Sphere4f : public SSE_Aligned_Object 

{

 vec4f  pos;

 float r;

 float rSquare;

}

now on msvc i have sizeof(Sphere4f ) == 32. that’s good.

but on nvcc i have sizeof(Sphere4f ) == 48. that’s bad

if i wrote

struct SSE_ALIGNED vec4f {/*some code*/}

on nvcc i have sizeof(Sphere4f ) == 32. that’s good.

but i want to use inheritance

How can we say if you don’t give the class definition of SSE_ALIGNED_OBJECT?

sorry, my guilt

struct SSE_ALIGNED SSE_Aligned_Object

{

#ifndef __CUDACC__

  static void* operator new(size_t size)

   {

   void* ptr = _aligned_malloc(size,16);

   if(!ptr)

    throw std::bad_alloc("_aligned_malloc(): unsufficient memory");

   return ptr;

   }

  static void operator delete(void* raw_memory)

   {

   if(!raw_memory) return;

  _aligned_free(raw_memory);

   }

 static void* operator new[](size_t size)

  {

   void* ptr = _aligned_malloc(size,16);

   if(!ptr)

    throw std::bad_alloc("_aligned_malloc(): unsufficient memory");

   return ptr;

  }

 static void operator delete[](void* raw_memory)

  {

   if(!raw_memory) return;

   _aligned_free(raw_memory);

  }

#endif

};

So, even when inheriting from an empty object you increase the size with 16 bytes? curious.

yes. on msvc sizeof(Sphere4f ) == 32 in that case. And that is size what i want.
ps: i don’t shure about gcc, but i heared it have similar problem when inheriting from an empty object.