This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: yet another wrong warning
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: Re: yet another wrong warning
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Wed, 1 Nov 2000 14:22:40 -0500
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <m3r94v5xab.fsf@otr.mynet.cygnus.com>
On Wed, Nov 01, 2000 at 11:04:28AM -0800, Ulrich Drepper wrote:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> $ cat v.c
> #define SWAP(x, y) ({ typeof(x) _tmp = x; x = y; y = _tmp; })
> int a;
> int b;
> void
> foo (void)
> {
> SWAP (a, b);
> }
> $ gcc -c -Wall v.c
> v.c: In function `foo':
> v.c:9: warning: value computed is not used
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Which value isn't used?
The result of the expression "y = _tmp;" I think. The ({...}) is one of
those expression compound statement GCC extension things, right? The last
statement in the list is evaluated as the value of the whole thing; that
value never gets used.
If you write "int c = SWAP (a, b);" -- yes, it's silly -- I would bet the
warning goes away. (Probably to be replaced by something about c never
being used.)
Phil
--
pedwards at disaster dot jaj dot com | pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools. Fools are protected by more capable fools.