GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Fix typecheck info for preferred_align_of<T>

Corrected return type for Rust's preferred_align_of intrinsic in GCC.

This commit fixes a type-checking issue in the GCC Rust compiler related to the preferred_align_of<T> intrinsic. Previously, the intrinsic incorrectly returned a unit type instead of a usize. This change ensures the intrinsic now returns the correct size type, improving the accuracy of type checking for alignment-related properties in Rust code compiled by GCC.

In Details

The gccrs frontend's type checker for intrinsics has been fixed. The preferred_align_of<T> intrinsic handler in rust-hir-type-check-intrinsic.cc was incorrectly returning void (unit type). This commit changes it to return usize, aligning with the expected type for alignment values and fixing a bug in the type-checking logic.

For Context
preferred_align_of<T>
A Rust intrinsic that returns the preferred alignment of a type T in bytes. This is often used in low-level code or when manually managing memory layouts.
usize
An unsigned integer type whose size is the same as that of a pointer on the target architecture. It's commonly used for indexing collections, sizes, and memory addresses.
unit type
In Rust, a type that has only one possible value, represented by (). It's often used for functions that do not return a meaningful value, similar to void in C.
Filed Under: gccrsrusttype-checkingintrinsics