GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: add repr_c_enums_larger_than_int lint

gccrs warns about non-portable #[repr(C)] enums larger than C int types.

A new lint in gccrs warns about Rust enums marked with #[repr(C)] whose discriminants exceed the size of C’s int or unsigned int. Such enums are non-portable because C standards (since C23) restrict enum sizes, and Rust’s isize interpretation for repr(C) discriminants might not match the C ABI. The discriminant is evaluated at compile time for this check.

In Details

gccrs now enforces a lint for #[repr(C)] enums where the discriminant value exceeds what can be represented by a C int or unsigned int. This addresses portability issues, as Rust's isize discriminant size may not align with C's expectations, especially post-C23. The check uses query_compile_const_expr to evaluate discriminants during type resolution, ensuring constant discriminants are handled correctly.

For Context
lint
A code analysis tool that flags programming errors, bugs, stylistic errors, and suspicious constructs. In compilers, lints provide warnings about potentially problematic code patterns.
repr(C)
A Rust attribute that specifies the memory layout of a data structure (like an enum or struct) should be compatible with the C programming language. This facilitates interoperability between Rust and C code.
enum discriminant
The underlying integer value associated with each variant of an enumeration. In #[repr(C)] enums, these values are intended to be compatible with C enums.
ABI
Application Binary Interface. Defines how low-level data is represented, how functions are called, and how different compiled components interact at the binary level.
Filed Under: gccrsrustcompilerlintABI