[notmuch] [PATCH 1/2] * avoid gcc 4.4.1 compiler warnings due to ignored write return values
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:
> 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
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
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
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).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the notmuch