yet another wrong warning

Geoff Keating geoffk@geoffk.org
Wed Nov 1 11:11:00 GMT 2000


Ulrich Drepper <drepper@redhat.com> writes:

> Another case where gcc is now too eager in writing warnings:
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> $ 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 value of the whole SWAP expansion, 'y'.  You probably meant

#define SWAP(x, y) ({ typeof(x) _tmp = x; x = y; y = _tmp; (void) 0; })

since I doubt you intended SWAP to return an integer.

-- 
- Geoffrey Keating <geoffk@cygnus.com>


More information about the Gcc-bugs mailing list