Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify static assert #16764

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading