E0712: Intrinsic align not power of two
| Code | Category | Stability |
|---|---|---|
E0712 | Intrinsic | Permanent |
Explanation
The byte-allocation family requires alignment to be a nonzero power-of-two byte count. Rue checks that contract at compile time whenever the align operand is a constant.
Likely cause
The constant alignment passed to @alloc, @alloc_zeroed, @free, @realloc, or @resize is zero or has more than one bit set, often because a size was used where an alignment was required. Use a valid alignment such as @align_of(T) converted to u64.
Examples
Allocate with a three-byte alignment
fn main() {
checked {
let block = @alloc(8, 3);
}
}
Use a power-of-two alignment
fn main() {
checked {
let block = @alloc(8, 8);
@free(block, 8, 8);
}
}