Created attachment 341194 [details] bogus.c Description of problem: gcc 4.4 has begun to emit a warning about a perfectly sensible (and difficult to avoid) construct Version-Release number of selected component (if applicable): gcc-4.4.0-0.34.i586 How reproducible: 100% Steps to Reproduce: 1. gcc -Wall -c bogus.c (-O level seems not to matter) Actual results: bogus.c: In function 'main': bogus.c:33: warning: value computed is not used bogus.c:33: warning: value computed is not used Expected results: Silence Additional info: The example is a simplified extract from the postgresql sources. This warning would only be reasonable if there were a better *and portable* way to do the same thing; I do not wish to hear about workarounds involving gcc-isms.
The right thing is obviously to cast the whole ?: to void instead of just one branch of the ?:, i.e. instead of (((isnull) != NULL) ? *(isnull) = false : (void) NULL), (Datum) tup[1] do ((void)(((isnull) != NULL) ? *(isnull) = false : false)), (Datum) tup[1] and similarly for true and 0 instead of false and tup[1]. The warning appeared with the tuples merge, but isn't reproduceable with current 4.5, I'll look at what actually changed in this regard in the mean time.
Hmm, if that's the "right thing" then the logical conclusion is that the LHS of every comma expression in the universe must be explicitly cast to void, else the compiler might harass you. Somehow I do not buy that.
It is a gcc bug and I've fixed it already upstream, see http://gcc.gnu.org/PR39889 This will be fixed in dist-f11 whenever I build new gcc (should be this week). The reason why I said the earlier is that it makes much more sense to cast to void the whole ?: than just one of the branches. And you wanted a portable way, not a gcc-ism. So I just explained a better and portable way as you requested. Normally, in comma expressions for -Wunused-values you need to cast to void whenever the LHS of it doesn't have side effects. Of course in this case there is a side-effect, so it is a compiler bug.
Should be fixed in gcc-4.4.0-3 in rawhide.