public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/100153] Undefined behavior in stl_bvector.h
Date: Wed, 24 Nov 2021 11:50:38 +0000	[thread overview]
Message-ID: <bug-100153-4-cOyegKHS4Q@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100153-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:c04b0f63243d4d474daa66f84874ebf6b9e7b0cd

commit r11-9281-gc04b0f63243d4d474daa66f84874ebf6b9e7b0cd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Apr 20 16:16:13 2021 +0100

    libstdc++: Do not allocate a zero-size vector<bool> [PR 100153]

    The vector<bool>::shrink_to_fit() implementation will allocate new
    storage even if the vector is empty. That then leads to the
    end-of-storage pointer being non-null and equal to the _M_start._M_p
    pointer, which means that _M_end_addr() has undefined behaviour.

    The fix is to stop doing a useless zero-sized allocation in
    shrink_to_fit(), so that _M_start._M_p and _M_end_of_storage are both
    null after an empty vector shrinks.

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/100153
            * include/bits/vector.tcc (vector<bool>::_M_shrink_to_fit()):
            When size() is zero just deallocate and reset.

    (cherry picked from commit 681707ec28d56494fa61a80c62500724d55f8586)

  parent reply	other threads:[~2021-11-24 11:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 14:10 [Bug libstdc++/100153] New: " hewillk at gmail dot com
2021-04-20 15:05 ` [Bug libstdc++/100153] " redi at gcc dot gnu.org
2021-04-20 15:32 ` redi at gcc dot gnu.org
2021-05-12  9:53 ` redi at gcc dot gnu.org
2021-10-01 19:38 ` cvs-commit at gcc dot gnu.org
2021-10-01 19:51 ` redi at gcc dot gnu.org
2021-11-24 11:50 ` cvs-commit at gcc dot gnu.org [this message]
2022-04-26 13:13 ` cvs-commit at gcc dot gnu.org
2022-05-09 16:40 ` cvs-commit at gcc dot gnu.org
2022-05-09 16:47 ` redi 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-100153-4-cOyegKHS4Q@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).