-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Labels
Milestone
Description
Started from mosra/magnum#505. Here's a reproducing example using just Corrade:
#include <Corrade/Containers/ArrayTuple.h>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Utility/Debug.h>
using namespace Corrade;
int main(int argc, char** argv)
{
Containers::ArrayView<std::pair<unsigned int, unsigned int>> arr;
Containers::ArrayTuple tuple{
{Containers::ValueInit, 4, arr}
};
for(std::size_t i = 0; i < arr.size(); ++i)
{
Utility::Debug{} << i;
if(arr[i].second != 0)
Utility::Debug{} << "Yes!";
}
return 0;
}Valgrind gives warnings about uninitialized memory after half of the array. I believe the problem is this line:
corrade/src/Corrade/Containers/ArrayTuple.cpp
Lines 280 to 283 in 1114af5
| /* If the item has a default constructor, call it on each element */ | |
| if(items[i]._constructor) | |
| for(std::size_t j = 0; j != items[i]._elementCount; ++j) | |
| items[i]._constructor(_data + offset + j*items[i]._elementAlignment); |
where it should be items[i]._constructor(_data + offset + j*items[i]._elementSize); - at least that fixes the valgrind errors.
Probably a unit test with larger structures is required, that tests whether the memory has been correctly initialized.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
Done