From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117733 invoked by alias); 14 Dec 2016 05:28:35 -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 117673 invoked by uid 89); 14 Dec 2016 05:28: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=H*Ad:U*roland, meyering, Hx-languages-length:2145, H*F:U*jim X-HELO: mail-io0-f196.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=N9fvazw+WSGQ2p4SeK+tdDRwMf8/dvCrT8uyE3EQ1DA=; b=Y22LLndhUO/6nziHqMZFK3xnvKCWTZm6Mpk9PkZEAraTJbqvOJbCjaigQUSLgMvlFg gvKdUNqsTMOBTMkOxUp/iLc+reMtQrcZIe8oNhOrycwB47k+Lh7/feXWcpcRn5pIC9vI Wqnx91pr1s/xaxakUjjYCawBWRT9L99H/oT0SEboAsY51HMh829KvanAjlB3tM9mlj2h JCSsH8KHubea4HeHOBwgl8gqoih/nT+z4Igvw3DjDhcQRUt286PKUGW8aZhqDxEA8qMm hGnGYyR573ACxUrkRPUY1xWPYAAMFhwwSNy+0G1ikxfdRIopmLAPE95ShwUzDTzGsVYN dejw== X-Gm-Message-State: AKaTC03wowBFzX9puvX/R7EimeRk7lRAJ0TrRxnNZ7F+5rj7Hu6f6o/xBaYvIMLYiJDZmbDlg9cmOOSijtHLWA== X-Received: by 10.36.214.67 with SMTP id o64mr5744852itg.31.1481693278143; Tue, 13 Dec 2016 21:27:58 -0800 (PST) MIME-Version: 1.0 In-Reply-To: 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: Wed, 14 Dec 2016 05:28: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-12/txt/msg00487.txt.bz2 On Thu, Dec 8, 2016 at 7:17 PM, Jim Meyering wrote: > On Fri, Nov 25, 2016 at 10:14 PM, Jim Meyering wrote: >> On Wed, Nov 23, 2016 at 11:36 PM, Florian Weimer wr= ote: >>> 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 = 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 >> >> 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= 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, to= o. >> The __STRICT_ANSI__ disjunct is to avoid the warning that -Wpeda= ntic >> would otherwise issue for the use of ({...}). I would have pref= erred >> 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 > > Here's the complete, rebased patch. Ok to push, presuming I still have > commit access? Friendly pre-holiday ping?