This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
target/10733: Modulus bug
- From: jbright at winfordeng dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 10 May 2003 15:28:45 -0000
- Subject: target/10733: Modulus bug
- Reply-to: jbright at winfordeng dot com
>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: