Bug 497545 - bogus "value computed is not used" warning
bogus "value computed is not used" warning
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-24 11:38 EDT by Tom Lane
Modified: 2013-07-02 23:22 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-04-27 16:12:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Tom Lane 2009-04-24 11:38:25 EDT
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 16:22:22 EDT
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 18:00:27 EDT
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 02:10:14 EDT
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 16:12:20 EDT
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.