#3616 compat/memcmp.c uses ++ on void*

obsolete: 8.4.14

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.


  • Donal K. Fellows

    • assigned_to: nobody --> mdejong
  • Donal K. Fellows

    • assigned_to: mdejong --> dkf
    • status: open --> closed-fixed
  • Donal K. Fellows

    Logged In: YES
    Originator: NO

    fixed in 8.4 branch and HEAD

  • Nobody/Anonymous

    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...)


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks