Am 09.12.18 um 10:22 schrieb 晓锋 李 via Sdcc-user:
> Hi:
> 
> 我想我遇到一个SDCC关于除法取余运算的BUG。
> I think I came across an SDCC bug about the divide operation.
> 
> 测试代码如下
> Test code is as follows:
> 
> void modtest2(unsigned int t)
> {
>       while(t != 0){
>               t % 10;
>               printf("t = %d, mod10 = %d\r\n", t, t%10);              
>               t = t / 10;
>       }
> }
> void mod_test(void)
> {
>       static unsigned int t = 1000;
>       modtest2(t);
> }
> 
> 问题应该是当执行除法运算后,再次执行取模运算,取模得到的结果不正确。
> The problem may be that after performing the division operation, the modulo 
> operation is performed again, and the result obtained by modulo is incorrect.
> 
> 以上代码测试结果如下:
> the test result is as follows:
> 
> t = 2943, mod10 = 3
> * t = 294, mod10 = 72
> t = 29, mod10 = 9
> t = 2, mod10 = 2
> t = 2944, mod10 = 4
> * t = 294, mod10 = 6
> t = 29, mod10 = 9
> t = 2, mod10 = 2
> 
> * 号标记的行,得到了错误结果
> The line marked by "*" is incorrect.
> 
> Sorry for my pool English,the English is translated by Google.

Which version of SDCC are you using (i.e. what is the output of sdcc
--version)? For which target do you compile?

I tried to reproduce the issue using sdcc 3.8.5 #10960 for the stm8 and
z80 targets, but the generated code looks correct to me.

Philipp


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to