1. Eu 2.3 trace BUG!

This is my code:

------------------ start ------------

function cekPrima(sequence bilPrima, atom cekangka)
atom isilist

        for j=1 to length(bilPrima) do
            isilist=bilPrima[j]
            if (cekangka/isilist - floor(cekangka/isilist))=0 then
                --bukan bil prima
                return 0
            else
                --bilprima
                if power(isilist,2)>cekangka then
                    return 1
                end if
            end if
        end for
        
        return 1

end function

sequence p
p = {2, 3}

for i = 3 to 10000 by 2 do
    if cekPrima(p, i)=1 then
        p &= i
    end if                   
end for 

? p

integer pos
integer jum

with trace
trace(1)

for i=2 to 100000000 do
        pos = 1
        jum = 1

        while 1 do
                if p[pos] > sqrt(i) then
                        exit
                elsif p[pos] = sqrt(i) then
                        jum += p[pos]
                else
                        pos += 1
                        if integer( i/p[pos] ) then
                                jum += i/p[pos] + p[pos]
                        end if
                end if
        end while
        
        if jum = i then
                ? i
        end if
end for

------------------------- end ----------------

Execute, and it will bring a trace window.

Highlighted: for i=2 to 100000000 do

Press DOWN. (don't press ENTER)

Press ?i

"i=9999" is displayed on left side??? it should be 2.

Press ENTER many times until "end for"

Press ENTER one time more.

"i=9999" in the left disappears, "i=3" appears in right side.

Press ?i

"i=3" in the right disappears, "i=9999" appears again in left side.





Is this really a bug?!

new topic     » topic index » view message » categorize

2. Re: Eu 2.3 trace BUG!

On 11 Apr 2002, at 21:18, akusaya at gmx.net wrote:

> 
> This is my code:
> 
> ------------------ start ------------
> 
> function cekPrima(sequence bilPrima, atom cekangka)
> atom isilist
> 
>         for j=1 to length(bilPrima) do
>             isilist=bilPrima[j]
>             if (cekangka/isilist - floor(cekangka/isilist))=0 then
>                 --bukan bil prima
>                 return 0
>             else
>                 --bilprima
>                 if power(isilist,2)>cekangka then
>                     return 1
>                 end if
>             end if
>         end for
> 
>         return 1
> 
> end function
> 
> sequence p
> p = {2, 3}
> 
> for i = 3 to 10000 by 2 do
>     if cekPrima(p, i)=1 then
>         p &= i
>     end if                   
> end for 
> 
> ? p
> 
> integer pos
> integer jum
> 
> with trace
> trace(1)
> 
> for i=2 to 100000000 do
>         pos = 1
>         jum = 1
> 
>         while 1 do
>                 if p[pos] > sqrt(i) then
>                         exit
>                 elsif p[pos] = sqrt(i) then
>                         jum += p[pos]
>                 else
>                         pos += 1
>                         if integer( i/p[pos] ) then
>                                 jum += i/p[pos] + p[pos]
>                         end if
>                 end if
>         end while
> 
>         if jum = i then
>                 ? i
>         end if
> end for
> 
> ------------------------- end ----------------
> 
> Execute, and it will bring a trace window.
> 
> Highlighted: for i=2 to 100000000 do
> 
> Press DOWN. (don't press ENTER)

Press ENTER. (Don't press DOWN)

> Press ?i
> 
> "i=9999" is displayed on left side??? it should be 2.

No, because the display will not update if you do not press ENTER. The i 
was 9999 from lines before.

> Press ENTER many times until "end for"
> 
> Press ENTER one time more.
> 
> "i=9999" in the left disappears, "i=3" appears in right side.

Because you pressed ENTER.
 
> Press ?i
> 
> "i=3" in the right disappears, "i=9999" appears again in left side.
> 
> 
> Is this really a bug?!

No. You should press ENTER.

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: Eu 2.3 trace BUG!

Aku writes:
> Is this really a bug?!

Yes. There's a known bug, originally reported by Ricardo Forno,
where the ? command in the trace facility can sometimes
get confused when you have multiple for-loops that use
the same loop variable.

Instead of reporting the value for the currently active loop variable 
"i", it might report the final value attained by "i" in some previous 
loop in the same routine, or perhaps both loops are at the top-level.
The previous "i" should have been forgotten, but it's actually
still in the symbol table, for various reasons. This can cause
the interactive ? command in trace to "see" the wrong variable. 
Execution of programs is not affected, just the value you see in
the trace window. I'll try to fix this for the next release. 
Thanks for the example code.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu