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

Jed Brown jed at 59A2.org
Mon Nov 23 06:24:46 PST 2009


On Mon, 23 Nov 2009 14:19:18 +0100, Karl Wiberg <kha at treskal.com> wrote:
> On Mon, Nov 23, 2009 at 12:11 PM, Dirk-Jan Binnema <djcb.bulk at gmail.com> wrote:
> 
> > On Mon, Nov 23, 2009 at 9:34 AM, Karl Wiberg <kha at treskal.com> wrote:
> >
> > > Didn't the "(void)" suggestion work?
> >
> > I actually preferred that solution, but unfortunately, it didn't
> > stop gcc from complaining...
> 
> Hmpf. I'd argue that that's a gcc bug, forcing the user to use an
> unnecessarily complicated way to pretend to use the return value. Oh
> well.

>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);

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


Jed


More information about the notmuch mailing list