[PATCH] gas: sframe: simplify get_offset_size_in_bytes
Jan Beulich
jbeulich@suse.com
Wed Jan 14 11:03:05 GMT 2026
On 14.01.2026 11:21, Jens Remus wrote:
> Type offsetT is either defined as signed 32-bit or 64-bit integer
> depending on whether BFD64 is defined. Do not test for whether an
> offsetT value exceeds INT32_MIN..INT32_MAX for !BFD64 32-bit offsetT
> (or INT64_MIN..INT64_MAX for BFD64 64-bit offsetT). This is always
> true and may result in a compile error when using compiler option
> -Werror=type-limits, such as the one resolved with commit
> 6b8fb74a9403 ("gas: sframe: do not test whether offsetT exceeds
> INT64_MIN..INT64_MAX") for BFD64 64-bit offsetT:
>
> ../../binutils-gdb/gas/gen-sframe.c: In function ‘get_offset_size_in_bytes’:
> ../../binutils-gdb/gas/gen-sframe.c:213:45: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> 213 | else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
> | ^~
> ../../binutils-gdb/gas/gen-sframe.c:213:67: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> 213 | else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
> | ^~
>
> Instead of testing for whether the value is in range of
> INT8_MIN..INT8_MAX, INT16_MIN..INT16_MAX, or INT32_MIN..INT32_MAX,
> test whether the value is unchanged when casted to int8_t, int16_t,
> or int32_t. This also improves readability.
>
> gas/
> * gen-sframe.c (get_offset_size_in_bytes): Simplify. Do not
> test whether !BFD64 32-bit offsetT exceeds INT32_MIN..INT32_MAX.
>
> Fixes: 58008ed4e6af ("gas: sframe: use standard min/max integer constants")
> Suggested-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Okay, and thanks.
Jan
More information about the Binutils
mailing list