Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
Qt Creator 12.0.0
-
None
Description
If I debug this program:
// main.cpp
#include <iostream> #include <deque> #include <cstdint> struct MyItem { MyItem(uint64_t a, uint16_t b) : a{a}, b{b} { } const uint64_t a; const uint16_t b; }; class Coll { public: Coll(std::size_t NUM) { dq.clear(); for (std::size_t i = 0; i != NUM; ++i) { dq.emplace_back(0, 0); } } void add(uint64_t a, uint16_t b) { dq.pop_front(); dq.emplace_back(a, b); print(); } void print() { for (auto it = dq.cbegin(); ;) { std::cout << '(' << it->a << ", " << it->b; ++it; if (it == dq.cend()) { std::cout << ")\n" << std::endl; break; } std::cout << "), "; } } private: std::deque<MyItem> dq; }; int main() { constexpr std::size_t NUM = 128; Coll coll(NUM); for (uint16_t i = 1; i != 7; ++i) { coll.add(i, i); } }
runnable with this CMakeLists.txt
cmake_minimum_required(VERSION 3.19)set(CMAKE_CXX_STANDARD 17) project(go LANGUAGES CXX)add_executable(go main.cpp)
then the deque dq will always have 128 items (ensured in the constructor).
If I debug and want to look into all 128 items, then from index 95 onwards, I see:
<not accessible>
Why?
Note: The function void add(uint64_t a, uint16_t b) will pop and item and add another one, so the there still always are 128 items.