Ticket UUID: | 0238027108506a3271543dcc297ac71d3cb41d3 | |||
Title: | Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error | |||
Type: | Bug | Version: | 8.6.8 | |
Submitter: | anonymous | Created on: | 2019-01-29 22:56:19 | |
Subsystem: | None | Assigned To: | nobody | |
Priority: | 5 Medium | Severity: | Important | |
Status: | Closed | Last Modified: | 2019-03-25 15:47:05 | |
Resolution: | Fixed | Closed By: | jan.nijtmans | |
Closed on: | 2019-03-25 15:47:05 | |||
Description: |
I quote the doc: TCL_ARGV_CONSTANT The argument does not take any following value argument. If this argument is present, the int pointed to by the srcPtr field is copied to the dstPtr field. The clientData field is ignored. But today, while programming an extension, I noticed that it's not "the int pointed to by the srcPtr field" but the pointer itself being put in dstPtr. When compiling the attached "test.c" and testing it, I get: $ gcc -shared -o test.{so,c} -DUSE_TCL_STUBS -I/usr/include -L/usr/lib64 -ltclstub8.6 $ tclsh > load ./test.so > test1 -opt 515178680 > test2 -opt 10 After looking at the source code, the solution is either applying diff --git a/tclIndexObj.c b/tclIndexObj.c index 30c33f1..07792c5 100644 --- a/tclIndexObj.c +++ b/tclIndexObj.c @@ -1207,7 +1207,7 @@ Tcl_ParseArgsObjv( infoPtr = matchPtr; switch (infoPtr->type) { case TCL_ARGV_CONSTANT: - *((int *) infoPtr->dstPtr) = PTR2INT(infoPtr->srcPtr); + *((int *) infoPtr->dstPtr) = *((int *) infoPtr->srcPtr); break; case TCL_ARGV_INT: if (objc == 0) { or changing the documentation to mean that it's the value being copied. | |||
User Comments: |
jan.nijtmans added on 2019-03-25 15:47:05:
Documentation fixed in: [b970ae4ac5]. Will be in next release. jan.nijtmans added on 2019-01-31 21:05:28: There actually is a test-case, testing for the actual current behavior: [artifact/76c4d17a5f6cca82?ln=7367] jan.nijtmans added on 2019-01-31 20:48:17: Actually, I don't know if TCL_ARGV_CONSTANT is useful in real life, but the problem is: If we change the actual behavior then current extensions using TCL_ARGV_CONSTANT will be broken by this changes. Therefore I would suggest to change the documentation. Thanks for reporting this! Maybe it - indeed - would be more logical to change the implementation, but it's too dangerous IMHO |