Skip to content

[VecOps] Interaction between memory adoption and clear yields wrong results #6796

@eguiraud

Description

@eguiraud

Describe the bug

Calling clear followed by push_back(x) on a RVec that is adopting memory results in the wrong value being "pushed back":

~ root -l                                                                (cern-root) 
root [0] ROOT::RVec<int> v{1,2,3}
(ROOT::RVec<int> &) { 1, 2, 3 }
root [1] ROOT::RVec<int> v2(v.data(), v.size())
(ROOT::RVec<int> &) { 1, 2, 3 }
root [2] v2[0] = 0
(int) 0
root [3] v
(ROOT::RVec<int> &) { 0, 2, 3 }
root [4] v2.clear()
root [5] v
(ROOT::RVec<int> &) { 0, 2, 3 }
root [6] v2.push_back(42)
root [7] v2
(ROOT::RVec<int> &) { 0 } // should be 42!!
root [8] v
(ROOT::RVec<int> &) { 0, 2, 3 }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions