From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3DCEA3858039; Thu, 27 Jan 2022 22:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DCEA3858039 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104017] unexpeted -Warray-bounds popping a fixed number of std::deque elements Date: Thu, 27 Jan 2022 22:55:49 +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: 9.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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, 27 Jan 2022 22:55:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104017 --- Comment #5 from Jonathan Wakely --- (In reply to Martin Sebor from comment #1) > This test case also triggers a warning, for the same reason: GCC can't > determine the relationship between a deque's internal node pointers and t= he > result of std::deque::size() (which is a function of the node pointers). Is the warning in this case coming from this function? void pop_back() _GLIBCXX_NOEXCEPT { __glibcxx_requires_nonempty(); if (this->_M_impl._M_finish._M_cur !=3D this->_M_impl._M_finish._M_first) { --this->_M_impl._M_finish._M_cur; _Alloc_traits::destroy(_M_get_Tp_allocator(), this->_M_impl._M_finish._M_cur); } else _M_pop_back_aux(); } I don't see what size() has got to do with anything, we explicitly check th= at _M_cur is not the start of the node. With -D_GLIBCXX_ASSERTIONS the first line of the function expands to: __glibcxx_assert(!this->empty()) but it still warns. What else are we supposed to do there to let the compiler know the object w= e're destroying is valid? Do we need to add a third way to check the deque is not empty?=