On Tue, May 06, 2014 at 03:29:37PM -0700, Junio C Hamano wrote: > > We can work around this by encapsulating the constant return > > value in a static inline function, as gcc specifically > > avoids complaining about unused function returns unless the > > function has been specifically marked with the > > warn_unused_result attribute. > > That's kind of W*A*T magic, and I generally try to avoid magic, as > long as it solves your "can we make both -O2 with new compilers and > -O3 happy?" I wouldn't complain ;-) I agree it's rather magical, but I think it's something we can count on. Certainly turning on warn_unused_result for every function would be a catastrophe for most code bases, and I don't expect gcc to do it. It's possible it would eventually grow smart to say "eh, I inlined this and realized that you don't use the return value", but I think that would be similarly a bad idea. And it does work with -O2 and -O3 with both gcc-4.9 and clang in my tests. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html