Skip to content

Commit 5a6b682

Browse files
committed
Fix invalid size calculation in nested_array
1 parent 15a7d65 commit 5a6b682

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/kernel_float/storage.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ KERNEL_FLOAT_DEFINE_VECTOR_TYPE(double, double1, double2, double3, double4)
428428

429429
template<typename V, size_t N>
430430
struct nested_array {
431-
static constexpr size_t num_packets = N / vector_size<V>;
431+
static constexpr size_t num_packets = (N + vector_size<V> - 1) / vector_size<V>;
432+
static_assert(num_packets * vector_size<V> >= N, "internal error");
432433

433434
V packets[num_packets];
434435

single_include/kernel_float.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//================================================================================
22
// this file has been auto-generated, do not modify its contents!
3-
// date: 2023-03-29 14:26:08.035035
4-
// git hash: 0d24d7110b4f2f45b8dbc511637a75f7d9aa0f73
3+
// date: 2023-03-31 15:49:21.313654
4+
// git hash: 15a7d65de3867323ab1b14f1d624c45ed733d904
55
//================================================================================
66

77

@@ -724,7 +724,8 @@ KERNEL_FLOAT_DEFINE_VECTOR_TYPE(double, double1, double2, double3, double4)
724724

725725
template<typename V, size_t N>
726726
struct nested_array {
727-
static constexpr size_t num_packets = N / vector_size<V>;
727+
static constexpr size_t num_packets = (N + vector_size<V> - 1) / vector_size<V>;
728+
static_assert(num_packets * vector_size<V> <= N, "internal error");
728729

729730
V packets[num_packets];
730731

0 commit comments

Comments
 (0)