public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview]
Message-ID: <bug-104017-4-pfee9e0DDK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104017-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104017
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(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 the
> 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
!= 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 that
_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 we're
destroying is valid? Do we need to add a third way to check the deque is not
empty?
next prev parent reply other threads:[~2022-01-27 22:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 22:52 [Bug middle-end/104017] New: " msebor at gcc dot gnu.org
2022-01-13 23:16 ` [Bug tree-optimization/104017] " msebor at gcc dot gnu.org
2022-01-18 11:12 ` larsbj at gullik dot net
2022-01-27 22:43 ` redi at gcc dot gnu.org
2022-01-27 22:44 ` redi at gcc dot gnu.org
2022-01-27 22:55 ` redi at gcc dot gnu.org [this message]
2022-05-12 14:37 ` [Bug tree-optimization/104017] unexpected " larsbj at gullik dot net
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-104017-4-pfee9e0DDK@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).