[notmuch] [PATCH 1/2] * avoid gcc 4.4.1 compiler warnings due to ignored write return values

Carl Worth cworth at cworth.org
Tue Dec 1 07:57:30 PST 2009


On Mon, 23 Nov 2009 15:24:46 +0100, Jed Brown <jed at 59A2.org> wrote:
> >From the gcc man page:
> 
>        -Wunused-value
>            Warn whenever a statement computes a result that is explicitly
>            not used. To suppress this warning cast the unused expression
>            to void. This includes an expression-statement or the left-
>            hand side of a comma expression that contains no side effects.
>            For example, an expression such as x[i,j] will cause a
>            warning, while x[(void)i,j] will not.
> 
>            This warning is enabled by -Wall.
> 
> But I'm confused here because I don't currently see any warnings with
> gcc-4.4.2.  Actually this must be a bug because I get no warnings for
> the blatantly unused
> 
>   malloc(5);

I'm guessing that the -Wunused-value warning doesn't consider values
computed by function calls.

> with -Wall -Wextra -pedantic.  Anyway, if your system headers specify
> __attribute__((warn_unused_result)) for write, then you could be running
> into this bug/feature
> 
>   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35579

Yes, this is the attribute that's triggering the warnings. I poked
around in the glibc headers to see how to get this warning myself, and I
finally found:

	make CFLAGS="-O -D_FORTIFY_SOURCE"

That makes the warning appear even with gcc 4.3.4, (and the definitions
in the headers suggest it will work with any gcc >= 4.1).

So I've pushed the patch now, (with an updated commit message to reflect
the above analysis).

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20091201/40d12278/attachment-0001.pgp>


More information about the notmuch mailing list