Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-01-23
11:11 • Ticket [1631017fff] compat/memcmp.c uses ++ on void* status still Closed wit... artifact: 21d3145980 user: nobody
2007-01-22
16:57 • Closed ticket [1631017fff]. artifact: fee1c23216 user: dkf
2007-01-18
18:50 • Ticket [1631017fff]: 1 change artifact: d9307804f6 user: dkf
2007-01-09
00:37 • New ticket [1631017fff]. artifact: 287b379db6 user: rrh

compat/memcmp.c uses ++ on void*

Closed / Fixed1631017fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2007-01-09 00:37:46
The file compat/memcmp.c uses ++ on void* pointers.  I believe that doing arithmetic on void* pointers is explicitly undefined in the C standard; it is an error to do so in C++.

Perhaps it would be better to cast the void * pointers given as arguments to unsigned char * pointers, and then do arithmetic on those pointers; that way ++ almost surely increments by 1.

I found this because the compiler I use issues a warning message for this construct, and then increments the void * pointer by 8 for each ++ operation; our compiler is likely doing the "wrong" thing relative to long-standing convention.
dkf Ticket [1631017fff]: 1 change [History diff]2007-01-18 18:50:26
dkfplain2007-01-22 16:57:24
Logged In: YES 
user_id=79902
Originator: NO

fixed in 8.4 branch and HEAD
nobodyplain2007-01-23 11:11:30
Logged In: NO 

The real bug is that compat/memcmp.c is being used in the first place -
if the build system is trying to use this file at all, it indicates that
the configure script has failed to detect a working C compiler.

(This might be because there is no working C compiler on the system,
but Tcl can't and shouldn't try to do anything about that...)
Log in (anonymous is fine) to add a comment.