Skip to content

Commit

Permalink
Merge pull request #181 from ValeevGroup/evaleev/fix/uninitialized-me…
Browse files Browse the repository at this point in the history
…tadata-in-constexpr-rank-range

initializes unused metadata in constexpr-rank arrays
  • Loading branch information
evaleev authored Sep 27, 2024
2 parents 1cfcb12 + 2323bd7 commit c25b0a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions btas/array_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions unittest/range_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ TEST_CASE("Range")
typedef RangeNd<blas::Layout::RowMajor, std::array<size_t, 3>> Range3d;
Range3d x;
CHECK(x.rank()== 3);
CHECK(x.area()== 0);
Range3d x1(std::array<int,0>{},std::array<int,0>{});
CHECK(x1.rank()== 3);
CHECK(x1.area()== 0);
}
SECTION("Col-major std::vector-based Range")
{
Expand Down

0 comments on commit c25b0a1

Please sign in to comment.