From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 9EDAE3858C74; Fri, 26 Aug 2022 10:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EDAE3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661511555; bh=dSwDQ4Doj5Ud6uXUb3Y4IZuss7TnRDckMLYEEscoVnM=; h=From:To:Subject:Date:From; b=mi1rKa9RRsZZ0BRp+Y9vCDBoe9aJ4CM7RzjRvzMH1OfoKo98iuahNVeRA1Fb3EiQ5 WEXiK+T3bpOSNUkwk+ydZ0VJUwGj4fJfNCgToia0c5XKYkjkjaLJDj1lxyjshRigDM bgFE961O9e3xDQ+GmBZGpohNypxJob65bzDYCl2g= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2219] New testcase for uninit X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: d6621a2f3176dd6a593d4f5fa7f85db0234b40d2 X-Git-Newrev: fc1b5707faf0b607da06e9ec3437245aba69a255 Message-Id: <20220826105915.9EDAE3858C74@sourceware.org> Date: Fri, 26 Aug 2022 10:59:15 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fc1b5707faf0b607da06e9ec3437245aba69a255 commit r13-2219-gfc1b5707faf0b607da06e9ec3437245aba69a255 Author: Richard Biener Date: Fri Aug 26 12:56:30 2022 +0200 New testcase for uninit The following adds a testcase that illustrates a defect in compute_control_dep_chain and its attempt to identify loop exits as special to continue walking post-dominators but failing to do so for following post-dominators. On trunk there is now simple_control_dep_chain saving the day, avoiding the false positive but with GCC 12 we get a bogus diagnostic. * gcc.dg/uninit-pred-11.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/uninit-pred-11.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gcc/testsuite/gcc.dg/uninit-pred-11.c b/gcc/testsuite/gcc.dg/uninit-pred-11.c new file mode 100644 index 00000000000..734df379ef7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pred-11.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +extern unsigned bar (void); +extern void quux (void); +int z; +unsigned foo (unsigned v, int y) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + // This variation from uninit-25.c causes compute_control_dep_chain + // to run into a defect but simple_control_dep_chain saves us here + if (y) + z = 1; + if (v != 1) + return u; /* { dg-bogus "may be used uninitialized" } */ + + return 0; +}