WHILE() failing to detect FALSE case
|
|
Bugzilla Link |
862 |
Created on |
Aug 25, 2011 20:23 |
Resolution |
FIXED |
Resolved on |
Oct 10, 2011 17:39 |
Version |
svn |
OS |
Linux |
Architecture |
PC |
Attachments |
crud.sac |
Extended Description
Created an attachment (id=813)
source code to reproduce failure
A binary search code used in various fundamental APEX primitives
(set membership, indexof...) seems to have gone haywire, some
time ago, but I only had a chance to look at it now.
Specifically, a while() loop starting off this way:
while ((first <= last) && !found) {
if( first > last) {
StdIO::show( tochar( "Bad!"));
}
manages to print "Bad". That's bad.
sac2c -V
sac2c v1.00-beta (Haggis And Apple)
developer rev 17569:MODIFIED linux-gnu_x86_64
(Thu Aug 25 13:10:01 EDT 2011 by sac)
apex@rattler:~/apex2003/benchmks/UTEpio$ sac2c crud.sac -v0
a.out apex@rattler:~/apex2003/benchmks/UTEpio$ a.out |more
Entering BinarySearch while()
0 3 99
2
[first,last]=
0 2
[first,last]=
0 0
Bad!
[first,last]=
1 0
Bad!
[first,last]=
1 0
Bad!
[first,last]=
1 0
Bad!
I was going to let it run to completion, but the nine billion names
aren't going to be done for a while yet...
The guts of the loop includes a conditional or two which, if removed,
make the code work OK.