libretro / bsnes2014

Libretro fork of bsnes. As close to upstream as possible.
GNU General Public License v3.0
9 stars 17 forks source link

Workaround for gcc7 compiler bug #41

Closed orbea closed 7 years ago

orbea commented 7 years ago

When compiled with gcc7, the bsnes-accuracy core will enter an infinite loop while compiling this code with -fstrict-aliasing.

 template<unsigned bits> inline uintmax_t uclip(const uintmax_t x) {
   enum : uintmax_t { b = 1ull << (bits - 1), m = b * 2 - 1 };
   return (x & m);
 }

This specifically happens with return x;.

As a temporary workaround until a proper solution can be found I suggest setting -fno-strict-aliasing for this particular code with a #pragma. This is further guarded so that it will only be applied for the accuracy profile and gcc newer than 7. I tested this with both gcc and clang where it compiled correctly.

See this issue for more information. https://github.com/libretro/bsnes-mercury/issues/47 and https://github.com/libretro/bsnes-mercury/pull/50