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

gccrs: Fixes bitshift compound assignment type check

gccrs corrects type checking for bitshift compound assignments.

The gccrs compiler now correctly type-checks bitshift compound assignment operations. Previously, the right-hand side operand was not consistently cast to match the type of the left-hand side for bitshift assignments, potentially leading to type errors or unexpected behavior. This fix aligns the behavior with arithmetic and logical compound assignments.

In Details

This commit corrects a type-checking oversight in gccrs for HIR::CompoundAssignmentExpr involving bitshift operations. The change in typecheck/rust-hir-type-check-expr.cc ensures that the right-hand side (RHS) operand is cast to the type of the left-hand side (LHS) operand, mirroring the handling for arithmetic and logical compound assignments. This addresses potential type mismatches when performing operations like x <<= y where x and y might have different types.

For Context
gccrs
The GCC backend for the Rust programming language, enabling Rust code to be compiled by GCC.
HIR
High-level Intermediate Representation. A representation of the code used after parsing and initial semantic analysis, before lower-level optimizations.
Compound Assignment
An assignment operation that combines a binary operation with an assignment, such as +=, -=, *=, <<=. For example, a <<= b is equivalent to a = a << b.
Type Checking
The process by which a compiler verifies that the types of operands in an expression or statement are compatible according to the language's rules.
Filed Under: gccrstype checkingcompiler bugs