NightDive-Studio / shockmac

System Shock (PowerMac version / Official GPL Release)
GNU General Public License v3.0
1.44k stars 182 forks source link

Inline operators in fixpp.h return reference to local #10

Open StrayLightning opened 6 years ago

StrayLightning commented 6 years ago

I haven't has a chance to look at the C++ standard, and there might be reasons or cases where this is okay. If the compiler guarantees to inline a function, the storage for the "local" notionally becomes local to the caller, so it could potentially be okay in some cases. However, g++ warns about these inline operators, and from looking at the unoptimised output they are not being inlined and the code emitted explicitly returns null.

This is worth bearing in mind for people who are porting the source to other toolchains.