From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 13ABD385840A; Fri, 29 Jul 2022 07:13:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13ABD385840A From: "raimue at codingfarm dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/106473] New: -Wanalyzer-malloc-leak false positive regression when returning heap-allocation through nested pointers Date: Fri, 29 Jul 2022 07:13:38 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: raimue at codingfarm dot de 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 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: Fri, 29 Jul 2022 07:13:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106473 Bug ID: 106473 Summary: -Wanalyzer-malloc-leak false positive regression when returning heap-allocation through nested pointers Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: raimue at codingfarm dot de Target Milestone: --- Source: void foo(char **args[], int *argc) { *argc =3D 1; (*args)[0] =3D __builtin_malloc(42); } Compiler output: $ gcc-12 -Wall -fanalyzer -c -o foo.o foo.c foo.c: In function 'foo': foo.c:4:1: warning: leak of '' [CWE-401] [-Wanalyzer-malloc-leak] 4 | } | ^ 'foo': events 1-2 | | 3 | (*args)[0] =3D __builtin_malloc(42); | | ^~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 4 | } | | ~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | | | | | (2) '' leaks here; was allocated at (1) | Notes: This is only reported with the write to argc happening first, which should = be considered completely unrelated to args. Reordering the two statements reso= lves the analyzer report. Tested versions: gcc 10.3: FAIL gcc 11.2: OK gcc 12.0: FAIL I therefore consider this a regression as it was not reported by gcc 11. Compiler Explorer link: https://gcc.godbolt.org/z/zGanPa3fs=