unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Carl Worth <cworth@cworth.org>
To: Jed Brown <jed@59A2.org>, Karl Wiberg <kha@treskal.com>,
	Dirk-Jan Binnema <djcb.bulk@gmail.com>
Cc: "notmuch@notmuchmail org" <notmuch@notmuchmail.org>,
	djcb@djcbsoftware.nl
Subject: Re: [PATCH 1/2] * avoid gcc 4.4.1 compiler warnings due to ignored write return values
Date: Tue, 01 Dec 2009 07:57:30 -0800	[thread overview]
Message-ID: <87ljhmadqt.fsf@yoom.home.cworth.org> (raw)
In-Reply-To: <87ws1h48up.fsf@59A2.org>

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

On Mon, 23 Nov 2009 15:24:46 +0100, Jed Brown <jed@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

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

      parent reply	other threads:[~2009-12-01 15:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-23  6:20 [PATCH 1/2] * avoid gcc 4.4.1 compiler warnings due to ignored write return values Dirk-Jan C. Binnema
2009-11-23  7:34 ` Karl Wiberg
2009-11-23 11:11   ` Dirk-Jan Binnema
2009-11-23 13:19     ` Karl Wiberg
2009-11-23 14:24       ` Jed Brown
2009-11-23 16:14         ` Dirk-Jan Binnema
2009-11-23 16:38           ` Jed Brown
2009-12-01 15:57         ` Carl Worth [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ljhmadqt.fsf@yoom.home.cworth.org \
    --to=cworth@cworth.org \
    --cc=djcb.bulk@gmail.com \
    --cc=djcb@djcbsoftware.nl \
    --cc=jed@59A2.org \
    --cc=kha@treskal.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).