Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 619a5edaccad1bafd3e05163d4cb3a2f8318538b539b3829456380aa90dcaad7
Ticket: 8dd2807066d7cc4d8604164f39b7f0d65c0dc321
bug in single-argument 'max' with bignums
User & Date: sebres on 2025-11-11 12:10:32
Changes

  1. icomment:
    <blockquote>> Let's discuss the changes in Tcl_TakeBignumFromObj() further.</blockquote>
    
    Agree.
    
    <blockquote>> I still prefer to simply replace Take with Get instead and not require any changes at the call site in `ExprMaxMinFunc`.</blockquote>
    
    It'd be unneeded if Jan had merged the whole fix of me, but...
    
    <blockquote>> A new bignum has to be created in either case.</blockquote>
    
    Well, I think this is exactly that, what Jan trying to achieve or rather to assume with "the current implementation makes sense" - the hope is that bignum can be moved from object to bignumValue pointer if it is unshared (so it'd be not created)... But, IMHO it is not correct - even with refCounts 1 (or 0), one can't guarantee that the object will be unused hereafter (or as Jan wrote "Tcl_TakeBignumFromObj() should only be used when the Tcl_Obj is Tcl_DecrRefCount'ed immediately"). So, IMHO, it is not correct to rely on refCounts in public function (however I'm OK if it'd happen always and panic if shared). 
    
    Just it is often the case that the objects supplied to <code>tcl::mathfunc::*</code> are shared (via arguments etc), so would be copied then.
    
    In any case, I don't understand why we can not use the value of <code>objPtr->internalRep.wideValue</code> directly for the comparison - shimmer is unexpected there, and the copy on read access is a bit unexpected to me therefore.
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"