This is an archive of the discontinued LLVM Phabricator instance.

Resize vector have does not work correctly
ClosedPublic

Authored by dorooleg on Apr 12 2018, 7:04 PM.

Details

Summary

When resize is done in smaller side need to move the pointer end

Vector<int> v;
v.PushBack(1);
v.PushBack(2);
v.Size(); // 1
v.Resize(1);
v.Size() // 2 but should be 1

Patch by Oleg Doronin

Diff Detail

Repository
rL LLVM

Event Timeline

dorooleg created this revision.Apr 12 2018, 7:04 PM
Herald added subscribers: Restricted Project, llvm-commits, kubamracek. · View Herald TranscriptApr 12 2018, 7:04 PM
vitalybuka added a subscriber: vitalybuka.EditedApr 12 2018, 7:10 PM

could you please extend compiler-rt/lib/sanitizer_common/tests/sanitizer_vector_test.cc ?

kcc added a subscriber: kcc.Apr 12 2018, 7:14 PM

Hm... interesting. how did you find it? what does this affect now?
I think it should be fixed in Resize().
Also, please add a test here: lib/sanitizer_common/tests/sanitizer_vector_test.cc

dorooleg updated this revision to Diff 142347.Apr 13 2018, 1:22 AM

@vitalybuka, @kcc thanks for the comments. ResizeReduction test was added into compiler-rt/lib/sanitizer_common/tests/sanitizer_vector_test.cc
As recommended by @kcc the changes are transferred to the method Resize
An error was found while attempting to use Vector in my own changes. How I see this error does not affect the current logic, so as to Resize is used to increase the size of the Vector

kcc accepted this revision.Apr 13 2018, 11:10 AM

LGTM, thanks!
Vitaly, please land.
This doesn't affect this review, but next time please upload patches with full context (the 'arc' tool is pretty good at it).

This revision is now accepted and ready to land.Apr 13 2018, 11:10 AM
vitalybuka accepted this revision.Apr 13 2018, 11:15 AM
vitalybuka edited the summary of this revision. (Show Details)

Update description

This revision was automatically updated to reflect the committed changes.