From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 78F6C3858C2C; Thu, 21 Apr 2022 22:51:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78F6C3858C2C From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105329] Bogus restrict warning when assigning 1-char string literal to std::string Date: Thu, 21 Apr 2022 22:51:08 +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: 12.0 X-Bugzilla-Keywords: diagnostic, missed-optimization, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: amacleod at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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, 21 Apr 2022 22:51:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105329 --- Comment #3 from Andrew Macleod --- Just to bookmark where the analysis is since im out for a few days, in the restrict pass, with ranger tracing on, the code sequence is: [local count: 14831835]: __nleft_49 =3D (const size_type) _48; __builtin_memcpy (_22, "5", __nleft_49); and the ranger trace from wrestrict shows: TRUE : (5628) range_of_expr (_48) long int [-INF, 0][2, +INF] TRUE : (5617) range_of_stmt (__nleft_49) const size_type [2, 9223372036854775807] So we know _48 is non-zero, and when I further delve into things, ranger is calculating __nleft_49 correct as [0, 0][2, +INF], but when it merges this with the current known global range, THAT has been set somewhere as [2, 9223372036854775807]=20 Im trying to find where the global value is first set. when I put a breakpo= int in the set and get routines, the very first thing that triggers is: #0 gimple_range_global (name=3D0x7fffefd0be10) at /opt/notnfs/amacleod/master/gcc/gcc/value-query.cc:419 #1 0x0000000002e73534 in ranger_cache::get_global_range (this=3D0x41797b8, r=3D..., name=3D0x7fffefd0be10) at /opt/notnfs/amacleod/master/gcc/gcc/gimple-range-cache.cc:925 #2 0x0000000002e73580 in ranger_cache::get_global_range (this=3D0x41797b8, r=3D..., name=3D0x7fffefd0be10, current_p=3D@0x7fffffff9c37: false) at /opt/notnfs/amacleod/master/gcc/gcc/gimple-range-cache.cc:939 #3 0x0000000002e6f731 in gimple_ranger::range_of_stmt (this=3D0x4179790, r= =3D..., s=3D0x7fffef265000, name=3D0x7fffefd0be10) at /opt/notnfs/amacleod/master/gcc/gcc/gimple-range.cc:307 #4 0x0000000002e6edc2 in gimple_ranger::range_on_entry (this=3D0x4179790, = r=3D..., bb=3D0x7fffeecc4340, name=3D0x7fffefd0be10) at /opt/notnfs/amacleod/master/gcc/gcc/gimple-range.cc:151 #5 0x0000000002e6ec40 in gimple_ranger::range_of_expr (this=3D0x4179790, r= =3D..., expr=3D0x7fffefd0be10, stmt=3D0x7fffeeca8f78) at /opt/notnfs/amacleod/master/gcc/gcc/gimple-range.cc:128 #6 0x0000000001b4cd0d in get_range (val=3D0x7fffefd0be10, stmt=3D0x7fffeec= a8f78, minmax=3D0x7fffffffbe10, rvals=3D0x4179790) at /opt/notnfs/amacleod/master/gcc/gcc/tree-ssa-strlen.cc:219 #7 0x00000000016f8fae in get_offset_range (x=3D0x7fffefd0be10, stmt=3D0x7fffeeca8f78, r=3D0x7fffffffc0b0, rvals=3D0x4179790) at /opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:92 #8 0x0000000001702c2f in handle_ssa_name (ptr=3D0x7fffef8d20d8, addr=3Dfal= se, ostype=3D0, pref=3D0x7fffffffc5d0, snlim=3D..., qry=3D0x4167468) at /opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:2157 #9 0x000000000170375b in compute_objsize_r (ptr=3D0x7fffef8d20d8, stmt=3D0x7fffeeca8f78, addr=3Dfalse, ostype=3D0, pref=3D0x7fffffffc5d0, snl= im=3D..., qry=3D0x4167468) at /opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:2321 #10 0x0000000001703907 in compute_objsize (ptr=3D0x7fffef8d20d8, stmt=3D0x7fffeeca8f78, ostype=3D0, pref=3D0x7fffffffc5d0, ptr_qry=3D0x41674= 68) at /opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:2355 #11 0x00000000016ff4e4 in pointer_query::get_ref (this=3D0x4167468, ptr=3D0x7fffef8d20d8, stmt=3D0x7fffeeca8f78, pref=3D0x7fffffffc5d0, ostype= =3D0) at /opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:1505 #12 0x00000000013b99c3 in (anonymous namespace)::pass_waccess::check_dangling_stores (this=3D0x4167410, bb=3D0x7fffeecc4340, stores=3D..., bbs=3D...) at /opt/notnfs/amacleod/master/gcc/gcc/gimple-ssa-warn-access.cc:4528 with p vr.dump(stderr) const size_type [1, 9223372036854775807] I also have a breakpoint in set_range_info for this name which hasn't been triggered. So either the set routine have been bypassed or perhaps inlini= ng is setting this global value? Im still trying to figure out who and where has decided that __nleft_49 is = [2, 0x7FFFFFFFFFFFFFFF] instead of [2, 0xFFFFFFFFFFFFFFFFFFFF]=