http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57974
--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Paolo Carlini from comment #5) > But isn't this a bug? I mean, naively, what do we gain from the optimization > point of view from not evaluating as 0 in any case? And why it happens only > for long double? Because long double always goes through x87. doubles and floats will fail your test with -m32 or -mfpmath=387 in addition to -funsafe-math-optimizations. BTW: The test does use infinty (which is IEEE thingy), and there is explicit warning that -funsafe-math-optimizations will violate these rules.