Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: daf97213ba322ec8b34d55adbf4eeffbd89c50e9
Ticket: 2089279fffffffffffffffffffffffffffffffff
StringObj.3 Tcl_ObjPrintf inaccuracies
User & Date: dgp on 2017-07-09 22:09:45
Changes

  1. icomment:
    
    For Tcl_ObjPrintf(), the format %lld DOES NOT MEAN (long long int).
    If you program as if it does, you will get crashes. Don't do that.
    
    The %d format means pull an (int) which is then pushed through
    losslessly as a Tcl_NewLongObj() to be formatted by [format %d]
    which expects to act on a (long int).
    
    (I know. That's a confusing mess, but [format] was already designed
    that way by the time I got to touch it.)
    
    This allows Tcl_ObjPrintf() to be similar to sprintf() in what C programmers
    expect to pass when using the %d specifier, while still re-using the same
    formatting engine already existing for [format].
    
    The %ld format means pull a (long int) which is then pushed through
    losslessly as a Tcl_NewWideIntObj() to be formatted by [format %ld]
    which expects to act on a (Tcl_WideInt).
    
    There is no way to pass a (long long int) or a (Tcl_WideInt) or a (size_t)
    argument to Tcl_ObjPrintf().  There's always been a /* TODO */ comment
    in the code noting this incompleteness.  More recently we've recorded the
    need to correct this in an RFE ticket.
    
    https://core.tcl.tk/tcl/tktview?name=3fbaa4e23b
    
    Jan Nijtmans has related work on the branch z_modifier
    and might have more on other branches I cannot find quickly
    right now.
    
  2. login: "dgp"
  3. mimetype: "text/plain"