Stephen Hill wrote: > I'm a newbie to GCC 4.x and I am getting lots of warnings about type > punning with code that use void** (I am using -O3). > I have functions declared to perform dynamic memory allocation that use > void**: > > bool RiMalloc(void **pBlock, int nSize); > void RiFree(void **pBlock); > > So, for example, we call the functions thus: > > typedef struct { > int x; > int y; > } tWibble; > > tWibble* void test_func(void) > { tWibble* pZ = NULL; > if (RiMalloc(&pZ, sizeof(tWibble))) > { > pZ->x = 5; > pZ->y = 10 > } > return pZ; > } > > Compiling this code with strict-aliasing enabled produces a warning. I get: p.c: In function 'test_func': p.c:13: warning: passing argument 1 of 'RiMalloc' from incompatible pointer type So this is a different case from the one that produces the strict-aliasing warning. This is a hard error, not a warning. What is the real strict-aliasing code? Andrew. #include <stddef.h> int RiMalloc(void **pBlock, int nSize); void RiFree(void **pBlock); typedef struct { int x; int y; } tWibble; tWibble* test_func(void) { tWibble* pZ = NULL; if (RiMalloc(&pZ, sizeof(tWibble))) { pZ->x = 5; pZ->y = 10; } return pZ; }