I think it's been fixed ages ado... can't remember when... however, conversion from unsigned to signed may result in negative value of destination if MSB of source is set in 1.
~d On Monday 15 December 2003 22:46, Matthias Weingart wrote: > Hi Dimitry, > > run the software below and at the end you get x=1 (should be 0!!) > > It seems that gcc uses the flags of sub for the next if(); but it should do > a additional cmp !! (first it is a unsigned operation, then a signed) > > msp430-gcc main.c -mmcu=msp430x149 -g -O2 -ffunction-sections > -Wl,--gc-sections,-uInterruptVectors -o main.elf (gcc from the download, > maybe you have already fixed that bug??) > > #include <stdlib.h> > > int x=0; > > func1(uint a, uint b) > { > uint ud; > int d; > > ud = a-b; > d = ud; > if ( d<0 ) > x|=1; > } > > func2(uint a, uint b) > { > volatile uint ud; > volatile int d; > > ud = a-b; > d = ud; > if ( d<0 ) > x|=2; > } > > main() > { > func1(32768,20000); > func2(32768,20000); > } > > Matthias > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- /***************************************************************** ("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ `6_ 6 ) `-. ( ).`-.__.`) State Polytechnical Univ. (_Y_.)' ._ ) `._ `. ``-..-' Radio-Physics Departament _..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia (il),-'' (li),' ((!.-' +7 (812) 5403923, 5585314 *****************************************************************/