Luca,

Can you please post this as a bug report in the bug tracker so it won't
get lost?
https://sourceforge.net/p/sdcc/bugs/

Thanks,
Maarten


> Hi,
>
> I'm using sdcc to build z80 programs for cpm.
>
> I think I found a strange bug.
>
>
> The program test2.c should output
>      5 / 2.5 = 2
>
> but the output is instead
>      5 / 2.5 = 0
>
> here the main of test2.c (complete test case is in dropbox)
>
> int main()
> {
>      unsigned n = 5;
>      unsigned i = (unsigned) ( n / 2.5 );
>      printf( "%d / 2.5 = %d\n", n, i );
>      return EXIT_SUCCESS;
> }
>
> i is 5 / 2.5; that is 2, but sdcc compute the value 0 at compile time
> (see test2.asm)
>
> To test the produced program test2.com (or test1.com, the version with
> int instead of unsigned) zxcc can be used.
> For. ex
>    zxcc test1.com
> (zxcc is available here -> http://www.seasip.info/Unix/Zxcc/)
>
> test1.c use int and produce the correct result.
> test2.c use unsigned and produce the uncorrect one.
>
> sdcc -v
> SDCC :
> mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8
> 3.3.2 #8948 (Feb 18 2014) (Linux)
>
> In test1.c (the correct one) I get the warning
> test1.c:28: warning 110: conditional flow changed by optimizer: so said
> EVELYN the modified DOG
>
> I have put the test cases with build script named build.sh in dropbox ->
> https://dl.dropboxusercontent.com/u/54869628/sdcc-test.tgz
>
> MfG
>
> Luca.

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to