Skip to content

Commit

Permalink
Avoid a false positive compiler error with GCC 12
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Feb 18, 2025
1 parent 925b90b commit 4a223b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/alpaka/core/AlignedAlloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ namespace alpaka::core
{
ALPAKA_FN_INLINE ALPAKA_FN_HOST auto alignedAlloc(size_t alignment, size_t size) -> void*
{
return ::operator new(size, std::align_val_t{alignment});
if(size == 0)
{
return nullptr;
}
else
{
return ::operator new(size, std::align_val_t{alignment});
}
}

ALPAKA_FN_INLINE ALPAKA_FN_HOST void alignedFree(size_t alignment, void* ptr)
Expand Down

0 comments on commit 4a223b3

Please sign in to comment.