Ticket UUID: | cb90038a637ed2ff8338a9fe288940bad334a822 | |||
Title: | signed integer overflow during expr-34.22, expr-36.22 | |||
Type: | Patch | Version: | core-8-6-branch | |
Submitter: | chrstphrchvz | Created on: | 2022-02-17 15:24:10 | |
Subsystem: | 48. Number Handling | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2022-02-23 15:50:38 | |
Resolution: | Fixed | Closed By: | jan.nijtmans | |
Closed on: | 2022-02-23 15:50:38 | |||
Description: |
This command (as does test expr-34.22) triggers signed integer overflow (undefined behavior) when long is 32-bit: % ::tcl::mathop::% -0x80000000 3 tcl/generic/tclExecute.c:6289:24: runtime error: signed integer overflow: 3 * -715827883 cannot be represented in type 'long int' tcl/generic/tclExecute.c:6289:15: runtime error: signed integer overflow: -2147483648 - 2147483647 cannot be represented in type 'long int' 1 Similar issue for this command (and test expr-36.22) for 64-bit long long: % ::tcl::mathop::% -0x8000000000000000 3 tcl/generic/tclExecute.c:8547:23: runtime error: signed integer overflow: -3074457345618258603 * 3 cannot be represented in type 'long long int' tcl/generic/tclExecute.c:8547:14: runtime error: signed integer overflow: -9223372036854775808 - 9223372036854775807 cannot be represented in type 'long long int' 1 The attached patch uses the corresponding unsigned types to accommodate overflow in these edge cases. | |||
User Comments: |
jan.nijtmans added on 2022-02-23 15:50:38:
Fixed [42d07d1fe556c48a|here] Thanks for the report and the patch |
Attachments:
- cb90038a63.diff [download] added by chrstphrchvz on 2022-02-17 15:26:10. [details]