target/10733: Modulus bug
jbright@winfordeng.com
jbright@winfordeng.com
Sat May 10 17:22:00 GMT 2003
>Number: 10733
>Category: target
>Synopsis: Modulus bug
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Sat May 10 15:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: John Bright
>Release: avr-gcc (GCC) 3.2.3 20030221 (Debian prerelease)
>Organization:
>Environment:
Linux host system, AVR cross-compiler for Atmel AT90S8535
>Description:
C Source code:
--------------------------------
int t1;
t1=2;
t1=(t1+40)%30;
--------------------------------
This results in t1 having a value of 42.
Compile options:
avr-gcc -g -Os -Wall -Wstrict-prototypes -mmcu=at90s8535
I found this bug while using avr-gcc 3.0.3 (in Debian stable). I tried out with 3.2.3 and the same bug still exists.
>How-To-Repeat:
>Fix:
In the above example, the bug can be worked-around by doing the modulus separately:
t1=2;
t1=t1+40;
t1%=30;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list