* Stefan Seifert -- Saturday 03 December 2005 01:24: > as discussed already on IRC, there seems to be another gcc 4.0.2/SUSE > 1.0 problem: > engine sounds on the 737, Concorde and every other plane that uses > thrust_lb[0] as base for the engine sound calculation don't work on this > platform.
It turned indeed out to be yet another one of these ugly aliasing bugs with gcc 4.0.2 ([1] *AND* [2]!). In fastmath.hxx apparently reinterpret_cast doesn't work appropriately. Could explain why Alex' clean patch didn't work. Now the question is: should fgfs work around a broken gcc release, when there's hope that the next version will be fixed? Or is it not a bug, but something that will be in all gcc versions for the next time (I've not found any bug reports about it yet!). Anyway, attached is a patch that makes the turbines whine again, and some of us whine less. m. [1] 4.0.2 20050901 (prerelease) (SUSE Linux) [2] 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)) diff -u -p -r1.4 fastmath.hxx --- fastmath.hxx 8 May 2004 12:58:29 -0000 1.4 +++ fastmath.hxx 3 Dec 2005 14:37:33 -0000 @@ -54,16 +54,18 @@ void fast_BSR(float &x, register unsigne inline float fast_log2 (float val) { - int * const exp_ptr = reinterpret_cast <int *> (&val); - int x = *exp_ptr; - const int log_2 = ((x >> 23) & 255) - 128; - x &= ~(255 << 23); - x += 127 << 23; - *exp_ptr = x; + union { + float f; + int i; + } v; + v.f = val; + const int log_2 = ((v.i >> 23) & 255) - 128; + v.i &= ~(255 << 23); + v.i += 127 << 23; - val = ((-1.0f/3) * val + 2) * val - 2.0f/3; // (1) + v.f = ((-1.0f/3) * v.f + 2) * v.f - 2.0f/3; // (1) - return (val + log_2); + return (v.f + log_2); } _______________________________________________ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d