.
D 2023-08-13T15:47:58.957
J assignee nobody
J closer nobody
J cmimetype text/x-markdown
J comment `lset`\sis\ssupposed\sto\sonly\sallow\ssetting\sof\selements\sfor\sout\sof\sbounds\sindices\swhen\sthe\sspecified\sindex\sis\sjust\safter\sthe\slast\svalid\sindex\s(i.e.\sequal\sto\slist\slength).\sHowever\sconsider\s\r\n\r\n```\r\n%\sset\sL\s{}\r\n%\slset\sL\s0x7ffffffffffffffe\sX\r\nindex\s"0x7ffffffffffffffe"\sout\sof\srange\r\n%\slset\sL\s0x7fffffffffffffff\sX\r\nX\r\n%\slset\sL\s0x7fffffffffffffff\sX\r\nindex\s"0x7fffffffffffffff"\sout\sof\srange\r\n```\r\n\r\nWhen\sthe\slist\sis\sempty,\sthe\sindex\s0x7fffffffffffffff\s(or\shigher)\sis\sincorrectly\streated\sas\sindex\s0\s(i.e.\sjust\sbeyond\slast\svalid\sindex).\sAs\sthe\sfirst\sline\sshows,\ssmaller\sout\sof\sbounds\sindices\sare\streated\scorrectly.\sAs\sthe\slast\sline\sshows,\sthis\sbug\sonly\soccurs\swhen\sthe\slist\sis\sempty.\r\n\r\nLike\sbug\s[bc076f4f0e](https://core.tcl-lang.org/tcl/tktview/bc076f4f0e),\sthis\sbug\swas\salso\sintroduced\sby\scommit\s[0b05b5c750df](https://core.tcl-lang.org/tcl/info/0b05b5c750df)\sintended\sto\sfix\sTIP\s577\sissues\sin\sTk.\r\n\r\nWhile\sthis\sissue\smay\sbe\sconsidered\srelatively\sminor,\sit\spoints\sto\swhat\sI\sthink\sis\sa\sfundamental\sflaw\sin\sinternal\sindex\sencoding\sin\sTcl:\sthe\snumber\sof\svalues\sthat\sneed\sto\sbe\srepresented\sin\san\s"index"\sare\sgreater\sthan\sthe\srange\sof\sthe\sindex\stype,\sno\smatter\swhether\s32-\sor\s64-bits.\sThis\sis\sdue\sto\snon-negative\sintegers\sbeing\svalid\s(for\sobvious\sreasons),\snegative\sintegers\sbeing\svalid\s(as\send-N)\srepresentation,\swhich\stogether\soccupy\sthe\sentire\sdomain.\sThen\sthere\sis\sa\sneed\sfor\sadditional\svalues\srepresenting\s"end"\sand\s"one\sbeyond\send"\sfor\swhich\sthere\sis\sno\sroom\snecessitating\shacks\slike\s[this](https://core.tcl-lang.org/tcl/file?ci=df58824c7868a07c&name=generic/tclListObj.c&ln=2930-2931)\swhich\sis\sthe\scause\sof\sthe\sabove\sbug.\sRemoving\sthat\shack\swill\scause\s`lset`\sto\sfail\son\r\n\r\n```\r\nset\sL\s{}\s;\slset\sL\s0\sX\r\n```\r\n\r\nwhich\sshould\sbe\sallowed.\sChanging\sthe\score\sindexing\sroutines\sto\sfix\sthis\sbreaks\sTk\sindexing\sfor\snegative\s(in\sthe\sC\sAPI)\sand\send\srelative\sindices.\r\n\r\nGiven\sthe\sabove\slimitation\sin\srange\sof\svalues\sI\ssee\sno\sway\saround\sthis\sother\sthan\sliving\swith\sthe\sabove\sbug\sfor\s9.0.\sIf\sI\sam\swrong\sand\sanyone\shas\sa\ssolution,\splease\sverify\sit\sworks\swith\sboth\sTk\sand\sthe\sbigdata\stests\sfor\slarge\sindices.
J foundin 9.0
J is_private 0
J login apnadkarni
J priority 5\sMedium
J private_contact 9546e9877f1a8899e25a89082561ee694e7fb402
J resolution None
J severity Minor
J status Open
J submitter apnadkarni
J subsystem -\sNew\sBuiltin\sCommands
J title lset\son\sempty\slist\sis\sallowed\swhen\sindex\sargument\sis\slarge
J type Bug
K 13d3c0d764fa4cf1c0cf0577924d7a0be5a3fd2b
U apnadkarni
Z db2c6e48a68f0ad38bbfb5d4e3b8066c