From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104772 invoked by alias); 26 Nov 2016 06:15:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 104705 invoked by uid 89); 26 Nov 2016 06:15:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Heres, Here's, Hx-spam-relays-external:209.85.223.195, H*RU:209.85.223.195 X-HELO: mail-io0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=0tvzYCkdDMMwDED/qClwZcRQw5OoMIBBIyYrXlXGf7E=; b=cNNAoSci5suL+dhtj6eFRMyyJl4+U0ZZ8dC4q4xYppoORLLNZACgniKBDTHoSpyumw Th8tPEs5OlfLv3hZlSnoOgvTeqOsHWITztExpAJSBgcu54fMC7A65J1gwOKJlZ496Wyo 0tIvCKiyTfwEcB/d4IC0W+yv7VkpsyyL8rUQXoLVMl+eKmOJ96ZOWnrJjqcbPjpQg2SU os5aq6vLI2D0Zd3FVtKUaIQ4d3O6G3VPQkHrdHekhcFG4Hzo/00fNF4r2DzN8jStaPdx 0PpZ81yGSvZNwmDH/0nH8Ovy6QeXoAnlx8tfl37MvlMl61WAmLChSanXBl7Ry4jlzUmQ X7Ag== X-Gm-Message-State: AKaTC03+1CkZpTAbh4f0vOes1Xp4TZY89Ngt0DnMDoxApqOp7R+t46+QTvVjeJLRj3tsvd5w6Wh1hOtnW3dSFA== X-Received: by 10.107.149.144 with SMTP id x138mr10159294iod.23.1480140908747; Fri, 25 Nov 2016 22:15:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <93a7b09e-70b9-d11e-bfb5-e54e751c8db5@redhat.com> References: <1405537923-28692-1-git-send-email-jim@meyering.net> <20140716201505.34FF22C398F@topped-with-meat.com> <93a7b09e-70b9-d11e-bfb5-e54e751c8db5@redhat.com> From: Jim Meyering Date: Sat, 26 Nov 2016 06:15:00 -0000 Message-ID: Subject: Re: [PATCH] assert.h: allow gcc to detect assert(a = 1) errors To: Florian Weimer Cc: Roland McGrath , libc-alpha Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2016-11/txt/msg00956.txt.bz2 On Wed, Nov 23, 2016 at 11:36 PM, Florian Weimer 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=3Dpedantic k.c >> In file included from k.c:1:0: >> k.c: In function =E2=80=98main=E2=80=99: >> 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 ne= ed > 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 Let gcc detect assert(a =3D 1) errors. * assert/assert.h (assert): Rewrite assert's definition so that a s/=3D=3D/=3D/ typo, e.g., assert(errno =3D ENOENT) is not hidden fr= om 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 preferr= ed 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