On 02/04/10 12:17, Christoph Bartoschek wrote: > Hi, > > what is the recommended way to call __sync_val_compare_and_swap for a float > pointer? Does it not work with a float pointer? > On the platforms where the code should run a float is 4 bytes. Therefore we > casted to an int pointer which is also 4 bytes. However this gives us a > warning: > > warning: dereferencing type-punned pointer will break strict-aliasing rules > > How to do this correctly? Use a union: typedef union { int i; float f; ] u_t; u_t *up; u_t u, u1; u.f = floatval; u1.f = oldval; __sync_val_compare_and_swap (&up->i, u1.i, u.i); Andrew.