#1105 sdcc wrongly optimizes away variable assignment

closed-works-for-me
nobody
5
2013-05-25
2006-04-25
No

Hi,
I just use sdcc for two weeks now and have a problem
which I believe is a bug:

The following code snippet should measure the counter
value every 10 ms (or so) and output the difference
between the last measurement and the current counter
value.
However, sdcc seems to remove the 'oldx = x;'
assignment. It cannot be found anywhere in the asm
file (attached).

while(1) {
oldx = x;
x = TMR0L + 256 * TMR0H;
diff = x - oldx;
printf("Count: %ld (%ld, %ld) \n", x,
diff, oldx);
delay_ms(10);
}

What am I doing wrong?

sdcc snapshot is version "SDCC : mcs51/gbz80/z80/avr/ds
390/pic16/pic14/TININative/xa51/ds400/hc08 2.5.6 #
(Apr 24 2006) (UNIX)"

I run sdcc as "sdcc -mpic16 -p18f2550 badoptimization.c
"

Thanks.
Raphael

Discussion

  • Raphael Wimmer

    Raphael Wimmer - 2006-04-25

    Logged In: YES
    user_id=871004

     
  • Raphael Wimmer

    Raphael Wimmer - 2006-04-25

    badoptimization.c

     
  • Raphael Wimmer

    Raphael Wimmer - 2006-04-25

    Logged In: YES
    user_id=871004

     
  • Raphael Neider

    Raphael Neider - 2006-06-19

    Logged In: YES
    user_id=1115835

    Unreproducable in r4243, probably fixed on May, 20th.

     
  • Raphael Neider

    Raphael Neider - 2006-06-19
    • labels: --> pic16 target
    • milestone: --> unreproducable
    • status: open --> closed-works-for-me
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks