Ticket UUID: | 1c60dca3412236a4992ff57dae575a7df91b65f0 | |||
Title: | signed integer overflow in Tcl_SetBignumObj() | |||
Type: | Patch | Version: | core-8-6-branch | |
Submitter: | chrstphrchvz | Created on: | 2022-02-16 00:15:17 | |
Subsystem: | 48. Number Handling | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2022-02-16 16:12:12 | |
Resolution: | Fixed | Closed By: | jan.nijtmans | |
Closed on: | 2022-02-16 16:12:12 | |||
Description: |
UBSan (-fsanitize=signed-integer-overflow) errors for 32-bit long and 64-bit long long: % set a -0x8000000000000001; incr a 1 tcl/generic/tclObj.c:3576:6: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself -9223372036854775808 % set b -0x8000000000000001; incr b 0x7fffffff80000001 tcl/generic/tclObj.c:3550:6: runtime error: negation of -2147483648 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself -2147483648 As with [89de498973], this can be avoided by negating before casting, and by subtracting from 0 (binary minus) to avoid compiler warnings for unary minus with unsigned operand (e.g. MSVC /W2 warning C4146). See attached patch. | |||
User Comments: |
jan.nijtmans added on 2022-02-16 16:12:12:
Fixed[414608568a59da8a|here] Thanks for the report! |
Attachments:
- setbignumobj-sif.diff [download] added by chrstphrchvz on 2022-02-16 00:15:37. [details]