From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E5B13858407; Fri, 4 Nov 2022 15:11:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E5B13858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667574669; bh=ZXNbBX6+yZt7PCEyW+kLy2hCZ5STjwKAIVfD1jCYZqI=; h=From:To:Subject:Date:From; b=ZZzhPy44bO4ihRcJMZpdu9f5aHT0xGOR6kWPf+HDIl99mxkFQuvdJxxpSzeosIXtW sDIy7xSSQpTrYuu9xp7X2ah6SG9MYqLY8HpgdO24ohA19Pb5cVQhj864Jg+lUpd2OO yODa3bRbn3li4vWU16xKN8NMcV/lAqHDYfYc2Hzo= From: "geoffreydgr at icloud dot com" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBhbmFseXplci8xMDc1MjZdIE5ldzogLSAtV2FuYXl6ZXIt?= =?UTF-8?B?bnVsbC1kZXJlZmVyZW5jZSBmYWxzZSBwb3NpdGl2ZSB3aXRoICBkaWZmZXJl?= =?UTF-8?B?bnQgYmVoYXZpb3JzIHdoZW4gZGVsZXRlIHVucmVsYXRlZCBzdGF0ZW1lbnQg?= =?UTF-8?B?4oCcaW50ICplID0gMDvigJ0=?= Date: Fri, 04 Nov 2022 15:11:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: geoffreydgr at icloud dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107526 Bug ID: 107526 Summary: - -Wanayzer-null-dereference false positive with different behaviors when delete unrelated statement =E2=80=9Cint *e =3D 0;=E2=80=9D Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: geoffreydgr at icloud dot com Target Milestone: --- I encountered a false positive when compiling the following MCVE program w= ith gcc (trunk) with -fanalyzer -O0 in https://godbolt.org/z/ojqa7PjPf ``` #include void f(short *g) { int a =3D0; int b =3D (0 !=3D g); am: if (b) {=20 int *c =3D &b; *c =3D printf("NPD_FLAG\n"); } int *e =3D 0; // (3) 'g' is NULL=20=20 (*g)++;=20 if (a) goto am; } int main() {=20 short d=3D0; f(&d);=20 return 0; } ``` Gcc static analyzer reports dereference of NULL 'g' at line 4, which is a false positive. while it gives wrong path note (3) 'g' is NULL at line 12. If I delete line 12 as the following code, gcc analyzer does not report NPD warning anymore.The statement `int *e =3D 0; ` is unrelated to `g` , but gcc analyzer has different behaviors before and after deleting the statement. ``` #include void f(short *g) { int a =3D0; int b =3D (0 !=3D g); am: if (b) {=20 int *c =3D &b; *c =3D printf("NPD_FLAG\n"); } int *e =3D 0; // (3) 'g' is NULL=20=20 (*g)++;=20 if (a) goto am; } int main() {=20 short d=3D0; f(&d);=20 return 0; } ``` Do you have any thoughts about this false positive?=