diff --git a/btas/array_adaptor.h b/btas/array_adaptor.h index fc8bac2b..fb314e0d 100644 --- a/btas/array_adaptor.h +++ b/btas/array_adaptor.h @@ -32,6 +32,8 @@ namespace btas { static array construct(std::size_t n) { assert(n <= N); array result; + // fill elements n+1 ... N-1 with zeroes + std::fill_n(result.begin() + n, N - n, value_type{}); return result; } static array construct(std::size_t n, T value) { diff --git a/unittest/range_test.cc b/unittest/range_test.cc index b95b6619..c48f9f33 100644 --- a/unittest/range_test.cc +++ b/unittest/range_test.cc @@ -70,6 +70,10 @@ TEST_CASE("Range") typedef RangeNd> Range3d; Range3d x; CHECK(x.rank()== 3); + CHECK(x.area()== 0); + Range3d x1(std::array{},std::array{}); + CHECK(x1.rank()== 3); + CHECK(x1.area()== 0); } SECTION("Col-major std::vector-based Range") {