public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "larsbj at gullik dot net" <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: Tue, 18 Jan 2022 11:12:01 +0000 [thread overview]
Message-ID: <bug-104017-4-xUyI2pXCtg@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
Lars Gullik Bjønnes <larsbj at gullik dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |larsbj at gullik dot net
--- Comment #2 from Lars Gullik Bjønnes <larsbj at gullik dot net> ---
(In reply to Martin Sebor from comment #1)
...
> #include <deque>
>
> struct Node { Node const * parent = nullptr; };
>
> void func(Node const * n)
> {
> std::deque<Node const *> p;
>
> Node const * e = n;
>
> while (e != nullptr) {
> p.push_front(e);
> e = e->parent;
> }
>
> if (p.size ())
> p.pop_front();
> if (p.size ())
> p.pop_front();
> if (p.size ())
> p.pop_back();
> }
>
>
> 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).
This is also the case amended with a check that the std::deque::size is large
enough (for the same reason). In that case the crash can never happen, still
GCC12 warns/errors.
I agree that the first test case, and the warning from it, is helpful. However
this second one not so much.
next prev parent reply other threads:[~2022-01-18 11:12 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 [this message]
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
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-xUyI2pXCtg@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).