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

Fortran intrinsic functions support unsigned numbers

Fortran intrinsic functions LEADZ, POPCNT, POPPAR, and TRAILZ now correctly support unsigned integer arguments.

The Fortran intrinsic functions LEADZ (leading zero count), POPCNT (population count), POPPAR (population parity), and TRAILZ (trailing zero count) have been updated to properly support unsigned integer arguments. Previously, LEADZ and TRAILZ were rejected for unsigned types, while POPCNT and POPPAR worked but were undocumented for unsigned operands. This change extends the functionality and documentation to cover unsigned numbers, with a new test case added to verify the behavior.

In Details

This commit extends the functionality of several Fortran intrinsic functions to correctly handle unsigned integer types. The LEADZ and TRAILZ intrinsics, previously rejected for UNSIGNED types, now work due to an adjustment in their check routine. POPCNT and POPPAR already supported unsigned types but were not documented as such. The changes involve updates to intrinsic.cc and documentation in gfortran.texi and intrinsic.texi, along with a new test case unsigned_45.f90.

For Context
LEADZ
A Fortran intrinsic function that returns the number of leading zero bits in an integer argument.
POPCNT
A Fortran intrinsic function that returns the number of bits set to 1 (population count) in an integer argument.
POPPAR
A Fortran intrinsic function that returns the parity of the bits set to 1 in an integer argument (0 for even, 1 for odd).
TRAILZ
A Fortran intrinsic function that returns the number of trailing zero bits in an integer argument.
unsigned integer
An integer data type that can only represent non-negative values. Unlike signed integers, it does not use a bit to represent the sign.
Fortran intrinsic function
A built-in function provided by the Fortran language standard, such as SIN, COS, or MAXVAL, which can be used directly in Fortran programs.
Filed Under: Fortranintrinsic functions