Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 27b91fb5a2cce960c0e3ce11df9a87e3169b7ed8cea797602aaff9eb90793fe7
Ticket: 57bfcf43dd4bd6c2257c1063fc079d56ca169191
Remove unreachable code in Tcl_SetWideIntObj()
User & Date: chrstphrchvz on 2023-03-05 18:55:22
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    In <tt>Tcl_SetWideIntObj()</tt> (generic/tclObj.c):
    
    <pre>
        if ((wideValue &gt;= (Tcl_WideInt) LONG_MIN)
    	    &amp;&amp; (wideValue &lt;= (Tcl_WideInt) LONG_MAX)) {
    	TclSetLongObj(objPtr, (long) wideValue);
        } else {
    #ifndef TCL_WIDE_INT_IS_LONG
    	TclSetWideIntObj(objPtr, wideValue);
    <span style="color:firebrick">#else
    	mp_int big;<br />
    	TclBNInitBignumFromWideInt(&amp;big, wideValue);
    	Tcl_SetBignumObj(objPtr, &amp;big);</span>
    #endif
        }
    </pre>
    
    The section creating a bignum is only defined when <tt>Tcl_WideInt</tt> is <tt>long</tt>. But when <tt>Tcl_WideInt</tt> is <tt>long</tt>, the range check is always true: <tt>TclSetLongObj()</tt> is always called, and the bignum section is never used.
    
    I am not aware of any other similar examples of this in core Tcl.
    
  5. foundin changed to: "8.5.19, 8.6.13"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "chrstphrchvz"
  14. subsystem changed to: "10. Objects"
  15. title changed to: "Remove unreachable code in Tcl_SetWideIntObj()"
  16. type changed to: "Patch"