From: Zack Weinberg <zackw@panix.com>
To: Jim Meyering <jim@meyering.net>
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: Thu, 24 Nov 2016 02:59:00 -0000 [thread overview]
Message-ID: <CAKCAbMjLFnCEkU42OXm0ynY=RUA9umW1qcLDR3xG_3c71fPykg@mail.gmail.com> (raw)
In-Reply-To: <CA+8g5KFy4tk+H3t0BKoe=wQqsW+ea3ZtzOe2bb+xBUNbtxGBWg@mail.gmail.com>
On Wed, Nov 23, 2016 at 9:21 PM, Jim Meyering <jim@meyering.net> wrote:
[...]
Not commenting on anything else, but...
> 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; }
... Would you please file a feature-request with the gcc people asking
for something that turns __extension__ back off? It would be nice to
be able to get this right even in __STRICT_ANSI__ mode. I'm imagining
that your macro could look like
#define assert(expr) \
__extension__ ({ \
if (__noextension__ (expr)) \
; \
else
__assert_failed (...); \
(void)0; \
})
(Make clear that the parentheses in __noextension__(...) need to not
count for the purpose of -Wparentheses.)
zw
next prev parent reply other threads:[~2016-11-24 2:59 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 [this message]
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
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='CAKCAbMjLFnCEkU42OXm0ynY=RUA9umW1qcLDR3xG_3c71fPykg@mail.gmail.com' \
--to=zackw@panix.com \
--cc=jim@meyering.net \
--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).