http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48139

--- Comment #6 from sgunderson at bigfoot dot com 2011-03-16 22:59:53 UTC ---
(In reply to comment #5)
> So, there's no glibc bug, but I don't think this makes a compelling case for
> any particular gcc behavior. The "implementation" is gcc+glibc, so gcc could
> say that its implementation of lrint never sets errno, and all would be
> conforming. Or gcc could say that users will pick a libc based on whether they
> want errno to be set, and so it should emit the call. Or gcc could optimize
> lrint in C99 (where errno-setting is forbidden) but not in C1x (where it's
> allowed).

Well, if C99/C1x _allows_ gcc to do this, I'd say it's a missed optimization
opportunity not to. :-)

FWIW, my code is C++.

> One local workaround is to set __attribute__((optimize("no-math-errno"))) on
> the functions whose assembly contains the undesired call, but that's a bit
> fragile in the face of changing inlining decisions.

Indeed; in my case, the function is pretty much guaranteed to get inlined, so
I'd have to sprinkle those attributes around all the potential callers.

Reply via email to