From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4872B3857C5A; Thu, 23 Jul 2020 15:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4872B3857C5A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595516895; bh=O3SZGJtZJ5DaMh27WmKzlpv0vowadTGtzYlGh43FqoY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=T1UFyKhGCtFTegK9eWfAMUSJnjPijlNz4tqzwZ6wGPY8JG2/BS6i4RfcrYK7YIq1T M60/JCUco70r7utSKY0+Irf6OgmMERSagJzQFkK+ir8xlugxzvqkDPyJXSRGEanV6t f8d6uPbz+8OzJFwenXVYYt4hTUAhXdAbnX44RdO8= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96295] [11 Regression] -Wmaybe-uninitialized warning for range operator with reference to an empty struct Date: Thu, 23 Jul 2020 15:08:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: target_milestone short_desc bug_status everconfirmed assigned_to cf_reconfirmed_on cc Message-ID: In-Reply-To: References: 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, 23 Jul 2020 15:08:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96295 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |11.0 Summary|Wmaybe-uninitialized |[11 Regression] |warning for range operator |-Wmaybe-uninitialized |with empty range struct |warning for range operator | |with reference to an empty | |struct Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot g= nu.org Last reconfirmed| |2020-07-23 CC| |msebor at gcc dot gnu.org --- Comment #1 from Martin Sebor --- Confirmed. The warning detects and avoids triggering for objects of empty types but in the test case __for_range is a reference to such an object and= the logic doesn't consider those. The tweak below makes the warning go away. = Let me handle this. diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 2f0ff724cde..fa88cad841c 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -401,6 +401,8 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, The first_field() test is important for C++ where the predicate alone isn't always sufficient. */ tree rhstype =3D TREE_TYPE (rhs); + if (POINTER_TYPE_P (rhstype)) + rhstype =3D TREE_TYPE (rhstype); if (TYPE_EMPTY_P (rhstype) || (RECORD_OR_UNION_TYPE_P (rhstype) && (!first_field (rhstype)=