[PATCH v2] gas: sframe: use standard min/max integer constants
Jens Remus
jremus@linux.ibm.com
Tue Jan 13 13:32:07 GMT 2026
On 1/13/2026 1:25 PM, Jens Remus wrote:
> On 1/13/2026 11:03 AM, Indu Bhagat wrote:
>> On 1/9/26 3:26 AM, Jens Remus wrote:
>>> Replace the use of custom VALUE_{8|16|32|64}BIT constant definitions
>>> with the standard INT{8|16|32|64}_{MIN|MAX} ones from stdint.h.
>>>
>>> Besides improving readability this also fixes the issue that the
>>> smallest representable signed 8/16/32-bit integer value was
>>> erroneously sized as the next larger integer type. For example
>>> get_offset_size_in_bytes (INT8_MIN) returned 2 instead of 1, due
>>> to INT8_MIN (= -128) != -VALUE_8BIT (= -127):
>>>
>>> (gdb) call get_offset_size_in_bytes (-127)
>>> $1 = 1
>>> (gdb) call get_offset_size_in_bytes (-128)
>>> $2 = 2
>>>
>>> gas/
>>> * gen-sframe.c (VALUE_8BIT, VALUE_16BIT, VALUE_32BIT,
>>> VALUE_64BIT): Remove.
>>> (get_offset_size_in_bytes): Use standard min/max integer
>>> constants.
>>>
>>> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
>>
>> LGTM.
>
> Thank you for the review! Committed to mainline.
This triggered the following CI build failure:
../../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))
| ^~
Committed the following as obvious fix to mainline, as offsetT
cannot exceed the range INT64_MIN..INT64_MAX:
else if (sizeof (offsetT) > 4)
See patch "[COMMITTED] gas: sframe: do not test whether offsetT
exceeds INT64_MIN..INT64_MAX".
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list