From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 40FAA3858032; Wed, 19 Jan 2022 08:29:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40FAA3858032 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6727] gimple-ssa-warn-access: Fix up asan_test.C -Wdangling-pointer regression [PR104103] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: b834435c8fa4cb9424787fe3044a49fef7992de8 X-Git-Newrev: 53836c887a05db23ff3b9fc06f64e0ba78810ece Message-Id: <20220119082938.40FAA3858032@sourceware.org> Date: Wed, 19 Jan 2022 08:29:38 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2022 08:29:38 -0000 https://gcc.gnu.org/g:53836c887a05db23ff3b9fc06f64e0ba78810ece commit r12-6727-g53836c887a05db23ff3b9fc06f64e0ba78810ece Author: Jakub Jelinek Date: Wed Jan 19 09:28:25 2022 +0100 gimple-ssa-warn-access: Fix up asan_test.C -Wdangling-pointer regression [PR104103] As reported in the PR or as I've seen since the weekend, asan_test.C fails because of many warnings like: gcc/testsuite/g++.dg/asan/asan_test.cc:1157:10: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=] gcc/testsuite/g++.dg/asan/asan_test.cc:1157:10: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=] gcc/testsuite/g++.dg/asan/asan_test.cc:1162:27: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=] ... (lots of them). There are no dangling pointers though, the warning pass sees: some_automatic_var ={v} {CLOBBER}; .ASAN_MARK (POISON, &some_automatic_var, 8); and warns on that (both on user vars and on e.g. TARGET_EXPR temporaries). There is nothing wrong on that, .ASAN_MARK is compiler instrumentation, which doesn't even touch the variable in any way nor make it escaped. What it instead does is change bytes in the shadow memory corresponding to the variable to reflect that the variable is out of scope and make sure that access to it would be diagnosed at runtime. So, for all purposes of the -Wdangling-pointer and -Wuse-after-free warnings, we should ignore this internal call. 2022-01-19 Jakub Jelinek PR middle-end/104103 * gimple-ssa-warn-access.cc (pass_waccess::check_call): Don't check .ASAN_MARK calls. Diff: --- gcc/gimple-ssa-warn-access.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index f9508a1d211..c36cd5d45d4 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -4234,6 +4234,11 @@ pass_waccess::check_call (gcall *stmt) if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) check_builtin (stmt); + /* .ASAN_MARK doesn't access any vars, only modifies shadow memory. */ + if (gimple_call_internal_p (stmt) + && gimple_call_internal_fn (stmt) == IFN_ASAN_MARK) + return; + if (!m_early_checks_p) if (tree callee = gimple_call_fndecl (stmt)) {