Skip to content

Commit

Permalink
simplify static assert (#16764)
Browse files Browse the repository at this point in the history
* simplify static assert

* fix error
  • Loading branch information
0-v-0 authored Aug 5, 2024
1 parent 713a27c commit b02f718
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion druntime/src/core/stdcpp/allocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ version (CppRuntime_Microsoft)
{
enum size_t _Big_allocation_threshold = 4096;
enum size_t _Big_allocation_alignment = 32;
enum isPowerOf2(size_t v) = v && !(v & (v - 1));

static assert(2 * (void*).sizeof <= _Big_allocation_alignment, "Big allocation alignment should at least match vector register alignment");
static assert((v => v != 0 && (v & (v - 1)) == 0)(_Big_allocation_alignment), "Big allocation alignment must be a power of two");
static assert(isPowerOf2!_Big_allocation_alignment, "Big allocation alignment must be a power of two");
static assert(size_t.sizeof == (void*).sizeof, "uintptr_t is not the same size as size_t");

// NOTE: this must track `_DEBUG` macro used in C++...
Expand Down

0 comments on commit b02f718

Please sign in to comment.