Bug 497545 - bogus "value computed is not used" warning
Summary: bogus "value computed is not used" warning
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-24 15:38 UTC by Tom Lane
Modified: 2013-07-03 03:22 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-04-27 20:12:20 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
bogus.c (671 bytes, text/plain)
2009-04-24 15:38 UTC, Tom Lane
no flags Details

Description Tom Lane 2009-04-24 15:38:25 UTC
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.

Comment 1 Jakub Jelinek 2009-04-24 20:22:22 UTC
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.

Comment 2 Tom Lane 2009-04-24 22:00:27 UTC
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.

Comment 3 Jakub Jelinek 2009-04-27 06:10:14 UTC
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.

Comment 4 Jakub Jelinek 2009-04-27 20:12:20 UTC
Should be fixed in gcc-4.4.0-3 in rawhide.


Note You need to log in before you can comment on or make changes to this bug.