Skip to content
Tcl Source Code View Ticket
Login

View Ticket

string compare fails if preceded by expr

Closed / Fixed218593ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:02:53
OriginalBugID: 1380 Bug
Version: 8.0.3
SubmitDate: '1999-03-02'
LastModified: '1999-08-07'
Severity: MED
Status: Released
Submitter: pat
ChangedBy: hobbs
OS: Solaris
OSVersion: SunOS 5.6
Machine: Other
FixedDate: '1999-08-07'
FixedInVersion: 8.0.5
ClosedDate: '2000-10-25'


Name:
Ivan Prock

Extensions:
none

CustomShell:
none

ReproducibleScript:
set tcl_traceExec 3
set month 01
set day 08
# if the expr statement is commented-out, the [string compare] returns 1,
# otherwise we get the incorrect -1 because "01" gets converted to "1"
if {[expr $month < 01]} {}

puts "day = \[$day\]"
set x [string compare $day 01]
puts "x = $x"
exit 0;



ObservedBehavior:
1: (18) invoking "info" "patchlevel"                                   
1: (20) invoking "puts" "8.0.3"                                        
8.0.3                                                                  
                                                                       
Executing ByteCode 0x8b508, ref ct 2, epoch 0, interp 0x83e60(epoch 0) 
  Source: "1 < 1"                                                      
  Cmds 0, chars 5, inst 6, objs 1, aux 0, stk depth 2, code/src 28.80n 
 = 104(header)+6(inst)+24(objs)+0(exc)+0(aux)+0(cmd map)               
  Starting stack top=-1                                                
1: (70) invoking "puts" "day = [08]"                                   
day = [08]                                                             
1: (84) invoking "string" "compare" "08" "1"                           
1: (97) invoking "puts" "x = -1"                                       
x = -1                                                                 
1: (104) invoking "exit" "0"                                           
                                          



DesiredBehavior:
the string compare's behaviour shouldn't be affected by a previous command




This was a bug related to an overaggressive object compiler that
has since been fixed. 
-- 08/07/1999 hobbs
welch Closed ticket [218593ffff]. [History diff]2000-10-26 08:25:09
dgp Ticket [218593ffff]: 3 changes [History diff]2001-04-16 21:02:27
Log in (anonymous is fine) to add a comment.