Overview
| Artifact ID: | a7be3a81ab2de6a8e4d89ed5d09194781c4c975bdc8dfa082120593cb71e946c |
|---|---|
| Ticket: | 1c60dca3412236a4992ff57dae575a7df91b65f0
signed integer overflow in Tcl_SetBignumObj() |
| User & Date: | chrstphrchvz on 2022-02-16 00:15:17 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
UBSan (<tt>-fsanitize=signed-integer-overflow</tt>) errors for 32-bit <tt>long</tt> and 64-bit <tt>long long</tt>: <blockquote><pre> % set a -0x8000000000000001; incr a 1 <span style="font-weight:bold">tcl/generic/tclObj.c:3576:6:<span style="color:red"> runtime error: </span>negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself</span> -9223372036854775808 % set b -0x8000000000000001; incr b 0x7fffffff80000001 <span style="font-weight:bold">tcl/generic/tclObj.c:3550:6:<span style="color:red"> runtime error: </span>negation of -2147483648 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself</span> -2147483648 </pre></blockquote> 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. [https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146|MSVC <tt>/W2</tt> warning C4146]). See attached patch.
- foundin changed to: "core-8-6-branch"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "48. Number Handling"
- title changed to: "signed integer overflow in Tcl_SetBignumObj()"
- type changed to: "Patch"