Skip to content
Tcl Source Code View Ticket
Login

View Ticket

signed integer overflow during obj-31.6

Closed / Fixed4789e18fcba7534cf2ca908eee2cca032e955c6eCreated 5 years agoUpdated 5 years ago
Descriptionwiki2022-02-17 00:12:05
This command (equivalent to test obj-31.6) triggers signed integer overflow (undefined behavior), which the attached patch addresses:
% string index {} end--0x80000000    
tcl/generic/tclUtil.c:3846:15: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
tcl/generic/tclUtil.c:3770:26: runtime error: signed integer overflow: -1 + -2147483648 cannot be represented in type 'int'
Referenced by1
chrstphrchvzwiki2022-02-17 09:52:53

Does the patch address the existing overflow concerns in SetEndOffsetFromAny(), or did those refer to something else (e.g. whether an overflow made sense as a useful result)?

jan.nijtmanswiki2022-03-06 16:16:27

Thanks! Fixed now in [7913cae186572c3d].

This problem was already fixed in Tcl 8.7, thanks to TIP #502. Your patch does nothing more than eliminate the warnings using type-casts, it doesn't change the result for 8.6, so that's OK for 8.6.

Log in (anonymous is fine) to add a comment.