Bugfix: NDArary/NDView overflow in calculating number of elements (#322)
Build on RHEL9 / build (push) Successful in 2m38s
Build on RHEL8 / build (push) Successful in 3m10s
Run tests using data on local RHEL8 / build (push) Successful in 3m59s
Build on local RHEL8 / build (push) Successful in 2m45s

Fixed number of elements calculation that caused integer overflow. Now
return size_t instead of int.
This commit is contained in:
Erik Fröjdh authored and GitHub committed 2026-06-10 12:24:18 +02:00
1 parent b78ea64ea7
commit 17d04083a7
3 files changed
+21 -2

No files matched your search

+19
View File
@@ -8,8 +8,27 @@
#include <vector>
using aare::NDView;
using aare::num_elements;
using aare::Shape;
TEST_CASE("Calculate size from a shape") {
Shape<3> shape{2, 3, 4};
REQUIRE(num_elements(shape) == 24);
Shape<2> shape2{5, 5};
REQUIRE(num_elements(shape2) == 25);
Shape<1> shape3{10};
REQUIRE(num_elements(shape3) == 10);
Shape<3> shape4{1000, 512, 1024};
REQUIRE(num_elements(shape4) == 524288000);
// 10GB which is more than INT_MAX bytes
Shape<3> shape5{10000, 1024, 1024};
REQUIRE(num_elements(shape5) == 10485760000);
}
TEST_CASE("Element reference 1D") {
std::vector<int> vec;
for (int i = 0; i != 10; ++i) {