GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gccrs

gccrs: intrinsic: Add min_align_of_val

gccrs now supports the `min_align_of_val` intrinsic for runtime alignment checks, including Dynamically Sized Types.

The gccrs compiler has gained support for the min_align_of_val intrinsic. This intrinsic allows developers to determine the minimum alignment requirements of a value at runtime, even for Dynamically Sized Types (DSTs). The addition involves new handler functions and type-checking rules within the compiler’s backend and type system.

In Details

The min_align_of_val_handler has been implemented in rust-intrinsic-handlers.cc/.h and registered in generic_intrinsics within rust-compile-intrinsic.cc. The type checking for this intrinsic, including DSTs, is now handled by IntrinsicChecker::intrinsic_rules in rust-hir-type-check-intrinsic.cc. The MIN_ALIGN_OF_VAL constexpr value is also added to rust-intrinsic-values.h. This intrinsic provides runtime evaluation of alignment, crucial for memory layout decisions.

For Context
gccrs
The Rust front-end for GCC, enabling GCC to compile Rust code.
intrinsic
A function or operation that is directly supported by the compiler and often maps to a specific machine instruction or a highly optimized sequence of instructions. Intrinsics provide low-level access or specialized functionality.
min_align_of_val
A Rust intrinsic that returns the minimum required alignment in bytes for a given value at runtime. This is useful for memory allocation and data structure layout.
Dynamically Sized Types (DSTs)
In Rust, types whose size is not known at compile time, such as slices ([T]) and trait objects (dyn Trait). Their size and alignment are determined at runtime.
runtime
The period during which a program is executing. Runtime operations are performed while the program is running, as opposed to compile time.
alignment
The requirement that data in memory be placed at addresses that are multiples of a certain value (e.g., 4-byte alignment for 4-byte integers). Proper alignment can improve performance and is sometimes required by hardware.
Filed Under: gccrsrustintrinsicbackend