[C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)
Marek Polacek
polacek@redhat.com
Tue Jan 21 21:56:00 GMT 2014
On Tue, Jan 21, 2014 at 09:18:17PM +0100, Marc Glisse wrote:
> On Tue, 21 Jan 2014, Marek Polacek wrote:
>
> >--- gcc/libdecnumber/decNumberLocal.h.mp 2014-01-21 18:34:32.235540589 +0100
> >+++ gcc/libdecnumber/decNumberLocal.h 2014-01-21 19:04:12.173243034 +0100
> >@@ -155,8 +155,10 @@ see the files COPYING3 and COPYING.RUNTI
> > /* Store a uInt, etc., into bytes starting at a char* or uByte*. */
> > /* Returns i, evaluated, for convenience; has to use uiwork because */
> > /* i may be an expression. */
> >- #define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork)
> >- #define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork)
> >+ #define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2), \
> >+ (void)uswork)
> >+ #define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4), \
> >+ (void)uiwork)
>
> This looks wrong to me. The comment before says that those macros
> "return" uiwork, so you can't cast it to void in the macro. Options:
>
> 1) cast to void in the users of the macro:
> (void) UBFROMUS(acc+4, 0);
>
> 2) Make the macros not return (since none of the users use the
> return value), i.e. remove ", uiwork" at the end and update the
> comment before. (you may need to cast the return of memcpy to void,
> which makes more sense)
I went with 2). Still it looks kind of weird, but I don't care enough as long
as it bootstraps ;). I'll post a patch once the regtesting finishes.
Thanks.
Marek
More information about the Gcc-patches
mailing list