On Sunday-201404-27, 20:13, Jarkko Hietaniemi wrote: > On Sunday-201404-27, 18:37, Karl Williamson wrote: >> The makers of gcc refuse to consider casting to (void) to be a valid way >> of handling the return value of a function which is declared as having >> its return value not ignored. > > Had to see this myself... I started up a Linux image [1] and now I see > somewhat more clearly... oh, so, yes it's not so much a gcc issue alone, > though, but an interaction of gcvt() being marked up with the gcc > attribute warn_unused_result (in glibc, I guess). And (void) in gcc > failing to overcome that attribute. > > Maybe something like: > > #ifdef __GNUC__ > #define UNUSED_RESULT(v) ({ typeof(v) z = (v); (void)sizeof(z); }) > #else > #define UNUSED_RESULT(v) ((void)(v)) > #endif > > Or something. No idea how typeof fares across GCC versions (that > solution nicked from stackoverflow, we are not the first to have this > problem). Looks like __typeof__() is preferable, compilers that fake being gcc (like clang in OS X) get cranky with typeof(). Suggested patch attached. If adding PERL_UNUSED_RESULT to perl.h is too bold, a patch smaller in scope can go (again) to sv.c, though that would seem kind of silly.Thread Previous