From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4AEA43857C77; Sun, 3 Dec 2023 17:04:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AEA43857C77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701623048; bh=lnVIWJliviavjDHQgYIcH1Uz0kxV/1lyfYzO0zQ3C2U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oduqVQLbbysCKWeZYAGX2bsg0DnYpkBjpvhySBGUUBmDsgQOuC0mQwD2fvXwz5sVY 9dgn7cAAK2blywpczP92tO0wat+xd7LpMI7ylEcBPVFb40f8FeAd8sYzbOgBA7eIRm lhfjU9/faGg4AEJWNz/s8/lPSV95Qj16KzUPxrEY= From: "alx at kernel dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/112833] Missing warnings on restrict misuse Date: Sun, 03 Dec 2023 17:04:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alx at kernel dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112833 --- Comment #1 from Alejandro Colomar --- Oops, in the reproducer from above, I should only expect a warning at call site. The definition is correct, since all parameters are restrict, so it's free to copy one to the other. Here's a reproducer where the call is fine, but the definition is wrong, and the compiler doesn't realize: $ cat restrict.c=20 #include long bogus2_strtol(const char *s, char **restrict ep, int base); int main(void) { char buf[3] =3D "foo"; char *p =3D buf; bogus2_strtol(p, &p, -42); } long bogus2_strtol(const char *s, char **restrict ep, int base) { memcpy(*ep, s, 1); return base; } $ gcc -Wall -Wextra restrict.c -fanalyzer $ gcc -Wall -Wextra restrict.c -fanalyzer -O3=