Strict aliasing and allocation functions

Eljay Love-Jensen eljay@adobe.com
Thu Apr 8 14:26:00 GMT 2004


Hi Carsten,

How about this...

gcc -std=c99 -O3 -Wall -o x x.c

--------8<--------
#include <stdlib.h>
#include <stdio.h>

int alloc(size_t n, void* p)
{
     void* a;

     a = malloc(n);
     *(void**)p = a;
     return a == NULL;
}


int main(void)
{
     int *a, res;

     res = alloc(10, &a);
     free(a);

     return 0;
}
-------->8--------

HTH,
--Eljay



More information about the Gcc-help mailing list