.
D 2003-03-06T23:09:15
J assignee hobbs
J cmimetype text/plain
J comment I\shave\sfound\sa\sbug\sin\sTcl\s8.4.1\sfor\splatforms\swith\s64-bit\s\ninteger\ssupport\nenabled,\si.e.\swhere\s"#ifndef\sTCL_WIDE_INT_IS_LONG"\s\nis\strue.\n\nThe\sproblem\sis\sthat\sthe\sformat\sinternal\sfunction\streats\s\nintegers\n(%08x\sformat)\sas\s32-bit,\sand\supdates\sobject's\s\ninternal\s"cache"\svalue\sto\sbe\ntclIntType\sinstead\sof\stclWideIntType.\n\nThe\sdocs\sfor\sformat\ssay:\n\n#\sThe\sl\smodifier\sis\signored\sfor\sreal\svalues\sand\son\s64-bit\s\nplatforms,\n#\swhich\sare\salways\sconverted\sas\sif\sthe\sl\smodifier\swere\s\npresent\s(i.e.\n#\sthe\stypes\sdouble\sand\slong\sare\sused\sfor\sthe\sinternal\s\nrepresentation\n#\sof\sreal\sand\sinteger\svalues,\srespectively).\sIf\sthe\sh\s\nmodifier\sis\n#\sspecified\sthen\sinteger\svalues\sare\struncated\sto\sshort\s\nbefore\n#\sconversion.\sBoth\sh\sand\sl\smodifiers\sare\signored\son\sall\s\nother\n#\sconversions.\s\n\nbut\sI\scan\sget\sformat\sto\suse\sa\s32-bit\sinternal\s\nrepresentation\son\sa\s64-bit\nsystem,\swhich\scontradicts\sthe\sdocs\s(the\sdocs\smatch\smy\s\nidea\sof\swhat\sshould\nbe\shappening.)\n\nThe\scode\sto\sreproduce\sthe\sissue\sis\sas\sfollows:\n\n=========================================\n===================\nproc\stcl_ok\s{}\s{\n\s\s\s\sset\sa\s0xaaaaaaaa\n\n\s\s\s\sset\sb_1\s0xaaaa\n\s\s\s\sset\sb_2\saaaa\n\s\s\s\sset\sb\s"${b_1}${b_2}"\n\n\s\s\s\sif\s{$a\s!=\s$b}\s{\n\s\s\s\s\s\s\s\sputs\s"Test\sok_1:\sa\sNOT\sEQUAL\sb"\n\s\s\s\s}\selse\s{\n\s\s\s\s\s\s\s\sputs\s"Test\sok_1:\sa\sEQUALS\sb"\n\s\s\s\s}\n\n\s\s\s\sset\sx\s[format\s%08lx\s$a]\n\n\s\s\s\sif\s{$a\s!=\s$b}\s{\n\s\s\s\s\s\s\s\sputs\s"Test\sok_2:\sa\sNOT\sEQUAL\sb"\n\s\s\s\s}\selse\s{\n\s\s\s\s\s\s\s\sputs\s"Test\sok_2:\sa\sEQUALS\sb"\n\s\s\s\s}\n}\n\nproc\stcl_error\s{}\s{\n\s\s\s\sset\sa\s0xaaaaaaaa\n\n\s\s\s\sset\sb_1\s0xaaaa\n\s\s\s\sset\sb_2\saaaa\n\s\s\s\sset\sb\s"${b_1}${b_2}"\n\n\s\s\s\sif\s{$a\s!=\s$b}\s{\n\s\s\s\s\s\s\s\sputs\s"Test\serror_1:\sa\sNOT\sEQUAL\sb"\n\s\s\s\s}\selse\s{\n\s\s\s\s\s\s\s\sputs\s"Test\serror_1:\sa\sEQUALS\sb"\n\s\s\s\s}\n\n\s\s\s\sset\sx\s[format\s%08x\s$a]\n\n\s\s\s\s#\sformat\shas\schanged\s$a\sto\sint\sinternal\srepresentation\n\s\s\s\s#\sb\shas\sno\stype,\sso\sis\sinterpreted\sas\swide_int\n\s\s\s\s#\sa\sis\ssign-extended\s32->64\sto\smatch\sb's\ssize\n\s\s\s\s#\shence\sthis\scomparison\sfails\n\s\s\s\sif\s{$a\s!=\s$b}\s{\n\s\s\s\s\s\s\s\sputs\s"Test\serror_2:\sa\sNOT\sEQUAL\sb"\n\s\s\s\s}\selse\s{\n\s\s\s\s\s\s\s\sputs\s"Test\serror_2:\sa\sEQUALS\sb"\n\s\s\s\s}\n}\n\nputs\s$tcl_patchLevel\ntcl_ok\ntcl_error\n=========================================\n===================\n\nwhich\sprints:\n\n=========================================\n===================\n8.4.1\nTest\sok_1:\sa\sEQUALS\sb\nTest\sok_2:\sa\sEQUALS\sb\nTest\serror_1:\sa\sEQUALS\sb\nTest\serror_2:\sa\sNOT\sEQUAL\sb\n=========================================\n===================\n\nThe\sissue\sis\sthe\scode\sin\stclCmdAH.c\sin\sfunction\nTcl_FormatObjCmd\s(at\sline\s2187\sin\sTcl\s8.4.1)\n\nThis\ssays:\n\n=========================================\n===================\n#ifndef\sTCL_WIDE_INT_IS_LONG\n\s\s\s\s\s\s\s\sif\s(useWide)\s{\n\s\s\s\s\s\s\s\s\s\s\s\sif\s(Tcl_GetWideIntFromObj(interp,\s/*\sINTL:\sTcl\s\nsource.\s*/\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sobjv[objIndex],\s&wideValue)\s!=\sTCL_OK)\s{\n\s\s\s\s\s\s\s\s\s\s\s\sgoto\sfmtError;\n\s\s\s\s\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\s\s\s\s\swhichValue\s=\sWIDE_VALUE;\n\s\s\s\s\s\s\s\s\s\s\s\ssize\s=\s40\s+\sprecision;\n\s\s\s\s\s\s\s\s\s\s\s\sbreak;\n\s\s\s\s\s\s\s\s}\n#endif\s/*\sTCL_WIDE_INT_IS_LONG\s*/\n\s\s\s\s\s\s\s\sif\s(Tcl_GetLongFromObj(interp,\s\s\s\s\s\s\s\s/*\sINTL:\sTcl\s\nsource.\s*/\n\s\s\s\s\s\s\s\s\s\s\s\sobjv[objIndex],\s&intValue)\s!=\sTCL_OK)\s{\n\s\s\s\s\s\s\s\s\s\s\s\sgoto\sfmtError;\n\s\s\s\s\s\s\s\s}\n=========================================\n===================\n\nBut\sit\sshould\ssay\ssomething\smore\slike:\n\n=========================================\n===================\n#ifndef\sTCL_WIDE_INT_IS_LONG\n\s\s\s\s\s\s\s\sif\s(Tcl_GetWideIntFromObj(interp,\s/*\sINTL:\sTcl\s\nsource.\s*/\n\s\s\s\s\s\s\s\s\s\s\s\sobjv[objIndex],\s&wideValue)\s!=\sTCL_OK)\s{\n\s\s\s\s\s\s\s\s\s\s\s\sgoto\sfmtError;\n\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\sif\s(useWide)\s{\n\s\s\s\s\s\s\s\s\s\s\s\swhichValue\s=\sWIDE_VALUE;\n\s\s\s\s\s\s\s\s\s\s\s\ssize\s=\s40\s+\sprecision;\n\s\s\s\s\s\s\s\s\s\s\s\sbreak;\n\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\selse\s{\n\s\s\s\s\s\s\s\s\s\s\s\svalue_used_for_formatting\s=\swide_value\s&\s0xffffffff\n\s\s\s\s\s\s\s\s\s\s\s\s//\ssetup\sother\sformatting\sparams\shere?\n\s\s\s\s\s\s\s\s}\n#else\s/*\sTCL_WIDE_INT_IS_LONG\s*/\n\s\s\s\s\s\s\s\sif\s(Tcl_GetLongFromObj(interp,\s\s\s\s\s\s\s\s/*\sINTL:\sTcl\s\nsource.\s*/\n\s\s\s\s\s\s\s\s\s\s\s\sobjv[objIndex],\s&intValue)\s!=\sTCL_OK)\s{\n\s\s\s\s\s\s\s\s\s\s\s\sgoto\sfmtError;\n\s\s\s\s\s\s\s\s}\n#endif\s/*\sTCL_WIDE_INT_IS_LONG\s*/\n=========================================\n===================\n\ni.e.\son\s64-bit\sarchitectures,\sTcl\sshould\s*always*\sinterpret\s\nstrings\nas\s64-bit\snumbers,\sbut\sfollow\sthe\swording\sof\sthe\sdocs\son\s\nthe\sformat\nh/l\smodifiers\smore\sprecisely\sby\struncating\s64->32/16\sbits\s\ndepending\son\nwhether\sh/l\sare\sspecified,\sinstead\sof\sinterpreting\sthe\s\nnumber\sas\n64/32/(16?)\sdepending\son\swhether\sh/l\sare\sspecified.\n\nOn\sa\smore\sgeneral\snote,\sa\slot\sof\sthe\sTcl\scode\ssays\sthis:\n\n#if\sHAVE_A_64_BIT_TYPE\n\s\s\s\sdo_something_64\n\s\s\s\sbail\sout,\sor\swhatever\n#endif\n\s\s\s\sdo_something_32\n\nThis\sleads\sto\sthis\stype\sof\sbug.\sIt'd\sbe\sbetter\sif\severything\s\nsaid\sthis:\n\n#if\sHAVE_A_64_BIT_TYPE\n\s\s\s\sdo_something_64\n#else\n\s\s\s\sdo_something_32\n#endif\n\s\s\s\sany_common_code\n\nPlus,\sshouldn't\sthe\stclIntType\sbe\scompletely\sremoved\sif\s\n64-bit\snumbers\nare\senabled?\sOr,\smake\stclIntType\sa\s#define/whatever\sto\s\ntclInt32Type\sor\ntclInt64Type,\sso\sthat\sthere's\snever\sever\sa\spossibility\sof\s\nusing\sthe\nwrong\sinternal\srepresentation\sfor\san\sinteger.\n
J foundin obsolete:\s8.4.1
J priority 5\sMedium
J resolution None
J status Open
J submitter srwarren
J subsystem 11.\sConversions\sfrom\sString
J title format\s%08x\s32/64bit\sconfusion
J type Bug
K 699060ffffffffffffffffffffffffffffffffff
U srwarren
Z bbcd30470aebf44b17e8d4aaa64aed53