Skip to content

Commit 732f569

Browse files
committed
Rewrite to better test the improper behavior
Signed-off-by: James Brodman <[email protected]>
1 parent 8aa61d8 commit 732f569

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

sycl/include/CL/sycl/detail/aligned_allocator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ template <typename T> class aligned_allocator {
5353
pointer allocate(size_t Size) {
5454
size_t NumBytes = Size * sizeof(value_type);
5555
NumBytes = ((NumBytes - 1) | (MAlignment - 1)) + 1;
56-
if (0 == NumBytes)
56+
if (Size > NumBytes)
5757
throw std::bad_alloc();
5858

5959
pointer Result = reinterpret_cast<pointer>(

sycl/test/usm/badmalloc.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,5 @@ int main(int argc, char *argv[]) {
4141
p = malloc(-1, q, usm::alloc::unknown);
4242
assert(p == nullptr);
4343

44-
// Bad combos for aligned
45-
p = aligned_alloc(1, 0, q, usm::alloc::host);
46-
assert(p == nullptr);
47-
48-
p = aligned_alloc(1, 0, q, usm::alloc::device);
49-
assert(p == nullptr);
50-
51-
p = aligned_alloc(1, 0, q, usm::alloc::shared);
52-
assert(p == nullptr);
53-
54-
p = aligned_alloc(1, 0, q, usm::alloc::unknown);
55-
assert(p == nullptr);
56-
5744
return 0;
5845
}

0 commit comments

Comments
 (0)