FWIW: My experiences with -fstrict-aliasing is that it doesn't generate a warning every time there is an actual problem. This may be a source of hair loss if you are trying to correct all aliasing issues. I can't point to a concrete example or test case, but I do remember in my own projects having to manually find the issue because GCC didn't. Also, there is a lot of uses with the union of a float and an int -- these are technically illegal (see 3rd paragraph of http://davmac.wordpress.com/2010/02/26/c99-revisited/). I resolved all of my aliasing between float <-> int by using memcpy() or a simple asm function:
float I2F(int x); -> flds $4(%esp) ret On Wed, Jun 30, 2010 at 5:51 AM, Michael Menegakis <arx...@gmail.com> wrote: > Thanks. I also went and made the compiler warn about it. > > Places where "warning: dereferencing type-punned pointer will break > strict-aliasing rules [-Wstrict-aliasing]" occurs on gcc 4.6.0: > > code/qcommon/net_ip.c > code/renderer/tr_backend.c > code/renderer/tr_shade.c > code/renderer/tr_shade_calc.c: > code/renderer/tr_surface.c: > > On Wed, Jun 30, 2010 at 1:09 PM, Patrick Baggett > <baggett.patr...@gmail.com> wrote: > > Any time a float and int are used with aliased points, for short. > > e.g. > > int* x = (int*)&float_value; > > *x = 0x7F000000; //set to 1.0f or something > > > > union asdf { > > int x; > > float f; > > } var; > > var.f = 123.0f; > > var.x >>= 2; //aliasing issue. > > > > See C99 spec for what is/isn't legal. Check network and file code for > > problems. > _______________________________________________ > ioquake3 mailing list > ioquake3@lists.ioquake.org > http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org > By sending this message I agree to love ioquake3 and libsdl. >
_______________________________________________ ioquake3 mailing list ioquake3@lists.ioquake.org http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org By sending this message I agree to love ioquake3 and libsdl.