public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: Florian Weimer <fweimer@redhat.com>
Cc: Roland McGrath <roland@hack.frob.com>,
	libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] assert.h: allow gcc to detect assert(a = 1) errors
Date: Sat, 26 Nov 2016 06:15:00 -0000	[thread overview]
Message-ID: <CA+8g5KGiN54O-jV7-NEP-4a9FrP6tio0xp2J=V0x-QX4tfAz2A@mail.gmail.com> (raw)
In-Reply-To: <93a7b09e-70b9-d11e-bfb5-e54e751c8db5@redhat.com>

On Wed, Nov 23, 2016 at 11:36 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 11/24/2016 03:21 AM, Jim Meyering wrote:
>
>> We *do* need that __STRICT_ANSI__ disjunct.
>> Otherwise, this would evoke no warning:
>>
>>   $ gcc -isystem. -I. -Werror=pedantic k.c
>>   In file included from k.c:1:0:
>>   k.c: In function ‘main’:
>>   k.c:2:23: warning: ISO C forbids braced-groups within expressions
>> [-Wpedantic]
>>    int main() { assert ( ({1;}) ); return 0; }
>
>
> Agreed.
>
>> Tests I ran manually in a directory with the new assert.h file:
>
>
>> Do you require a test suite addition for these? If so, would a single
>> bourne shell script be acceptable?
>
>
> We currently lack the machinery for that.  It's not just that it would need
> a shell script.  We also do not compile tests with headers as system
> headers.
>
> The patch looks good to me, but it needs a ChangeLog entry.

Thanks for the review.
Here's a proposed ChangeLog entry:

2016-11-25  Jim Meyering  <meyering@fb.com>

        Let gcc detect assert(a = 1) errors.
        * assert/assert.h (assert): Rewrite assert's definition so that a
        s/==/=/ typo, e.g., assert(errno = ENOENT) is not hidden from
        gcc's -Wparentheses by assert-added parentheses.  The new
        definition uses "if (expr) /* empty */; else __assert_fail...",
        so gcc -Wall will now detect that type of error in an assert, too.
        The __STRICT_ANSI__ disjunct is to avoid the warning that -Wpedantic
        would otherwise issue for the use of ({...}).  I would have preferred
        to use __extension__ to mark that, but doing so would mistakenly
        suppress warnings about any extension in the user-supplied "expr".
        E.g., "assert ( ({1;}) )" must continue to evoke a warning.
        https://bugzilla.redhat.com/1105335

  reply	other threads:[~2016-11-26  6:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-16 19:12 Jim Meyering
2014-07-16 20:15 ` Roland McGrath
2014-07-16 20:44   ` Jim Meyering
2016-11-24  2:22     ` Jim Meyering
2016-11-24  2:59       ` Zack Weinberg
2016-11-24 13:13         ` Joseph Myers
2016-11-26  6:36           ` Jim Meyering
2016-11-24  7:36       ` Florian Weimer
2016-11-26  6:15         ` Jim Meyering [this message]
2016-12-09  3:21           ` Jim Meyering
2016-12-14  5:28             ` Jim Meyering
2016-12-14  9:13           ` Florian Weimer
2016-12-15  0:25             ` Jim Meyering
2016-12-16 12:15               ` Florian Weimer
2016-12-18  9:53                 ` Jim Meyering
2016-12-27 17:47               ` Andreas Schwab
2016-12-28 12:50                 ` Florian Weimer

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

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

  git send-email \
    --in-reply-to='CA+8g5KGiN54O-jV7-NEP-4a9FrP6tio0xp2J=V0x-QX4tfAz2A@mail.gmail.com' \
    --to=jim@meyering.net \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=roland@hack.frob.com \
    /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.
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).