public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107699] [12/13/14 Regression] False positive -Warray-bounds, non-existent offset reported by GCC
Date: Fri, 15 Dec 2023 13:57:16 +0000 [thread overview]
Message-ID: <bug-107699-4-cRjZryMqmT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107699-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107699
--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Carlos Galvez from comment #11)
> Consider this more realistic example:
>
> https://godbolt.org/z/jbbqbe8d9
>
> The compiler has all the information available to ensure that
> getCount().get() is smaller than 3, as enforced by the class invariant which
> is visible to the compiler. Class invariants help us not having to check
> things all the time. For example gsl::not_null allows us to not have to
> check for nullptr on every use.
This doesn't really change anything as the compiler doesn't see the
CTOR invoked or that 'x' isn't changed before being returned.
I think we want to somehow prevent the diagnostic on the library side.
This particular case is
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Compare>
_GLIBCXX20_CONSTEXPR
void
__final_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
if (__last - __first > int(_S_threshold))
{
std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
__comp);
}
else
std::__insertion_sort(__first, __last, __comp);
where we diagnose __first + int(_S_threshold) when that's visibly out-of-bounds
but __last - __first isn't constant. I'm not exactly sure how
(I'm also not sure why we do the above thing, handling the first elements
separate from the rest...)?
prev parent reply other threads:[~2023-12-15 13:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 14:10 [Bug c++/107699] New: " carlosgalvezp at gmail dot com
2022-11-16 13:34 ` [Bug tree-optimization/107699] " rguenth at gcc dot gnu.org
2022-11-16 13:34 ` [Bug tree-optimization/107699] 12/13 Regression] " rguenth at gcc dot gnu.org
2022-11-16 14:54 ` [Bug tree-optimization/107699] [12/13 " carlosgalvezp at gmail dot com
2022-11-23 3:00 ` hp at gcc dot gnu.org
2022-11-29 13:22 ` rguenth at gcc dot gnu.org
2022-11-29 13:41 ` carlosgalvezp at gmail dot com
2022-11-29 13:46 ` carlosgalvezp at gmail dot com
2022-11-29 17:54 ` rguenther at suse dot de
2022-11-29 17:58 ` carlosgalvezp at gmail dot com
2022-12-08 10:58 ` cvs-commit at gcc dot gnu.org
2022-12-08 10:59 ` rguenth at gcc dot gnu.org
2023-02-16 10:37 ` carlosgalvezp at gmail dot com
2023-05-08 12:26 ` [Bug tree-optimization/107699] [12/13/14 " rguenth at gcc dot gnu.org
2023-12-15 13:57 ` rguenth at gcc dot gnu.org [this message]
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-107699-4-cRjZryMqmT@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).