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/108197] [12/13 Regression] -Wstringop-overread emitted on simple boost small_vector code
Date: Thu, 22 Dec 2022 12:10:06 +0000	[thread overview]
Message-ID: <bug-108197-4-PPH5JuiUYy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108197-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108197

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
          Component|c++                         |tree-optimization
      Known to work|                            |11.3.1
             Status|UNCONFIRMED                 |NEW
            Summary|-Wstringop-overread emitted |[12/13 Regression]
                   |on simple boost             |-Wstringop-overread emitted
                   |small_vector code           |on simple boost
                   |                            |small_vector code
           Keywords|                            |diagnostic
             Blocks|                            |97048
   Last reconfirmed|                            |2022-12-22
   Target Milestone|---                         |12.3

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We have

<bb 6> [local count: 321929297]:
_58 = _43 * 4;
_40 = (signed long) _58;
_67 = _40 /[ex] 4;
sz_68 = (const size_type) _67;
if (_58 > 40)
  goto <bb 7>; [51.12%]
else
  goto <bb 16>; [48.88%]

<bb 7> [local count: 164570258]:
if (_58 > 9223372036854775804)
  goto <bb 8>; [0.00%]
else
  goto <bb 9>; [100.00%]

...

<bb 14> [local count: 133301908]:
__builtin_memcpy (_82, &MEM[(const struct small_vector_base
*)&pp].m_storage_start.data, _58);

so we get a constraint on _58, the lower bound causes us to warn.  The
.data field is only 4 bytes in size, so the access is clearly out
of bounds.  Maybe it is unreachable, the initialization seems to happen
in a function not inlined:

boost::container::expand_forward_and_insert_alloc.isra (&MEM[(struct
small_vector_base *)&pp].m_storage_start.data, &MEM[(struct small_vector_base
*)&pp].m_storage_start.data, 1);
_42 = MEM[(struct vector_alloc_holder *)&pp].m_size;

it looks like boost already uses always_inline a lot but it doesn't
forcefully expose the setting of m_size, so there's not much we can
do about this diagnostic.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97048
[Bug 97048] [meta-bug] bogus/missing -Wstringop-overread warnings

  reply	other threads:[~2022-12-22 12:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 10:10 [Bug c++/108197] New: " steveire at gmail dot com
2022-12-22 12:10 ` rguenth at gcc dot gnu.org [this message]
2022-12-24 17:21 ` [Bug tree-optimization/108197] [12/13 Regression] " steveire at gmail dot com
2023-01-13 12:49 ` rguenth at gcc dot gnu.org
2023-04-08 14:38 ` law at gcc dot gnu.org
2023-05-08 12:26 ` [Bug tree-optimization/108197] [12/13/14 " rguenth at gcc dot gnu.org

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-108197-4-PPH5JuiUYy@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).