]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix std::deque::size() Xmethod [PR112491]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 14 Nov 2023 15:08:13 +0000 (15:08 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 14 Nov 2023 22:40:17 +0000 (22:40 +0000)
commit99f992a275c30bc8db2e6352e98ab81c89b5b7ed
tree6f83dd2f94120e12b54817ac2ecb407573714e4b
parenta9ae1c53c0f2172ed691503afc413676bc6cf7df
libstdc++: Fix std::deque::size() Xmethod [PR112491]

The Xmethod for std::deque::size() assumed that the first element would
be at the start of the first node. That's only true if elements are only
added at the back. If an element is inserted at the front, or removed
from the front (or anywhere before the middle) then the first node will
not be completely populated, and the Xmethod will give the wrong result.

libstdc++-v3/ChangeLog:

PR libstdc++/112491
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.size): Fix
calculation to use _M_start._M_cur.
* testsuite/libstdc++-xmethods/deque.cc: Check failing cases.

(cherry picked from commit 4db820928065eccbeb725406450d826186582b9f)
libstdc++-v3/python/libstdcxx/v6/xmethods.py
libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc
This page took 0.063606 seconds and 6 git commands to generate.