Skip to content

Commit c9e28ff

Browse files
committed
Fix clang UBSan trigger in sbo_resource.hpp
1 parent 991a95b commit c9e28ff

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

include/boost/cobalt/detail/sbo_resource.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ struct sbo_resource
4141
}
4242
constexpr void align_as_max_()
4343
{
44-
const auto buffer = static_cast<char*>(buffer_.p) - static_cast<char*>(nullptr);
44+
const auto buffer = reinterpret_cast<std::uintptr_t>(buffer_.p);
4545
const auto diff = buffer % alignof(std::max_align_t );
4646
if (diff > 0)
4747
{
4848
const auto padding = alignof(std::max_align_t) - diff;
49-
buffer_.p = static_cast<void*>(static_cast<char*>(nullptr) + buffer + padding);
49+
buffer_.p = static_cast<char*>(buffer_.p) + padding;
5050
if (padding >= buffer_.size) [[unlikely]]
5151
{
5252
buffer_.size = 0;

0 commit comments

Comments
 (0)