Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Remove unreachable code in Tcl_SetWideIntObj()

Closed / Fixed57bfcf43dd4bd6c2257c1063fc079d56ca169191Created 4 years agoUpdated 4 years ago
Descriptionwiki2023-03-05 18:55:22
In Tcl_SetWideIntObj() (generic/tclObj.c):
    if ((wideValue >= (Tcl_WideInt) LONG_MIN)
	    && (wideValue <= (Tcl_WideInt) LONG_MAX)) {
	TclSetLongObj(objPtr, (long) wideValue);
    } else {
#ifndef TCL_WIDE_INT_IS_LONG
	TclSetWideIntObj(objPtr, wideValue);
#else
	mp_int big;
TclBNInitBignumFromWideInt(&big, wideValue); Tcl_SetBignumObj(objPtr, &big);
#endif }

The section creating a bignum is only defined when Tcl_WideInt is long. But when Tcl_WideInt is long, the range check is always true: TclSetLongObj() is always called, and the bignum section is never used.

I am not aware of any other similar examples of this in core Tcl.

Referenced by1
jan.nijtmanswiki2023-03-06 21:22:08

Fixed [1045bf69c59070c|here]

jan.nijtmanswiki2023-03-06 21:23:40

Fixed [here]

Log in (anonymous is fine) to add a comment.