From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7CCD13858D38; Thu, 13 Aug 2020 07:40:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CCD13858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597304459; bh=1Zsn7+fa6MZwiDfNyh7Kfm5vBuWeFdb7LipxdvfFNTo=; h=From:To:Subject:Date:From; b=af/gEo9qcel6X6NcWTWSvUQ33ck5vwNYuyDl5wCMIqgffdDqg1VZnYOV8POWHZJ4v Tbw6jmcnpVFryK4mDZK7t/di+JTYuo0qhtlJ/w4NDYDRwB4YK+BPjpV+ORPAmQNnri t2mnUskm7aR4Of5okGjelbbSEp1X8eo+CIgteAzQ= From: "dpotapov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96598] New: false NULL argument warning [-Wanalyzer-null-argument] Date: Thu, 13 Aug 2020 07:40:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dpotapov at gmail dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2020 07:40:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96598 Bug ID: 96598 Summary: false NULL argument warning [-Wanalyzer-null-argument] Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: dpotapov at gmail dot com Target Milestone: --- Created attachment 49054 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49054&action=3Dedit C code to demonstrate the problem A function receives an argument that is marked as non-NULL using __attribu= te__ ((__nonnull__ ())), and it uses this argument to invoke another function th= at also takes a non-NULL argument. The first invocation does NOT produce any warning as expected, but the second one does: test.c:67:9: warning: use of NULL =E2=80=98str=E2=80=99 where non-null expe= cted [CWE-690] [-Wanalyzer-null-argument] It looks strange considering the argument has not changed anywhere in the function. Also, it looks like the warning is triggered by defining an unrel= ated local variable. The warning happens only when the source code is compiled w= ith '-fanalyzer -fsanitize=3Dundefined'. The attached C file demonstrates the problem.=