Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-03-25
15:47 • Ticket [0238027108] Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error ... artifact: f06410a50f user: jan.nijtmans
2019-01-31
21:09 • Closed ticket [0238027108]. artifact: 81dde1ae4c user: jan.nijtmans
21:05 • Ticket [0238027108]: 3 changes artifact: 6cec17a27d user: jan.nijtmans
21:01
Fix [0238027108]: Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error check-in: b970ae4ac5 user: jan.nijtmans tags: core-8-6-branch
20:48 • Ticket [0238027108] Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error ... artifact: 9fb3b8992a user: jan.nijtmans
2019-01-29
23:00 • Add attachment tcl8.6.8_generic_tclIndexObj.c.patch to ticket [02380271... artifact: 995ad0f2cc user: anonymous
23:00 • Ticket [0238027108] Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error ... artifact: 679a3afc33 user: anonymous
22:57 • Add attachment test.c to ticket [0238027108] artifact: 892a3478cd user: anonymous
22:56 • New ticket [0238027108] Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error<... artifact: 1845801f5c user: anonymous

Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error

Closed / Fixed0238027108506a3271543dcc297ac71d3cb41d3fCreated 8 years agoUpdated 8 years ago
Descriptionplain2019-01-29 22:56:19
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.
Referenced by1
  • b970ae4ac5Fix [0238027108]: Tcl_ParseArgsObjv TCL_ARGV_CONSTANT documentation error check-in2019-01-31 21:01:25
anonymous Ticket [0238027108]: 3 changes [History diff]2019-01-29 23:00:13
jan.nijtmansplain2019-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
jan.nijtmanswiki2019-01-31 21:05:28

There actually is a test-case, testing for the actual current behavior: [artifact/76c4d17a5f6cca82?ln=7367]

jan.nijtmans Closed ticket [0238027108]. [History diff]2019-01-31 21:09:41
jan.nijtmanswiki2019-03-25 15:47:05

Documentation fixed in: [b970ae4ac5]. Will be in next release.

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