public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "regehr at cs dot utah dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/39635] New: integer wrong code bug on AVR Date: Sat, 04 Apr 2009 05:42:00 -0000 [thread overview] Message-ID: <bug-39635-12544@http.gcc.gnu.org/bugzilla/> (raw) See below. This bug was found using Avrora bug is reproducible in AVR studio. The problem exists in HEAD but not apparently in the 4.3 series. The generated code looks to be wrong at -O2 and -Os. regehr@john-home:~$ avr-gcc -v Using built-in specs. Target: avr Configured with: ../configure --prefix=/home/regehr/avrgcc440/install --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp : (reconfigured) ../configure --prefix=/home/regehr/avrgcc440/install --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp : (reconfigured) ../configure --prefix=/home/regehr/avrgcc440/install --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp Thread model: single gcc version 4.5.0 20090403 (experimental) (GCC) regehr@john-home:~$ avr-gcc -O1 -mmcu=atmega128 small.c -o small.elf regehr@john-home:~$ java avrora.Main -colors=false -monitors=break small.elf Avrora [Beta 1.7.107] - (c) 2003-2007 UCLA Compilers Group Loading small.elf...[OK: 0.060 seconds] =={ Simulation events }======================================================= Node Time Event ------------------------------------------------------------------------------ 0 178 break instruction @ 0x0130, r30:r31 = 0x0001 ============================================================================== Simulated time: 179 cycles Time for simulation: 0.061 seconds Total throughput: 0.0029344263 mhz regehr@john-home:~$ avr-gcc -O2 -mmcu=atmega128 small.c -o small.elf regehr@john-home:~$ java avrora.Main -colors=false -monitors=break small.elf Avrora [Beta 1.7.107] - (c) 2003-2007 UCLA Compilers Group Loading small.elf...[OK: 0.057 seconds] =={ Simulation events }======================================================= Node Time Event ------------------------------------------------------------------------------ 0 166 break instruction @ 0x0122, r30:r31 = 0x0C00 ============================================================================== Simulated time: 167 cycles Time for simulation: 0.061 seconds Total throughput: 0.002737705 mhz regehr@john-home:~$ cat small.c #include <stdint.h> #include <limits.h> #define safe_mod_macro_uint8_t_u_u(ui1,ui2) \ ((((uint8_t)(ui2)) == ((uint8_t)0)) \ ? ((uint8_t)(ui1)) \ : (((uint8_t)(ui1)) % ((uint8_t)(ui2)))) static uint8_t safe_mod_func_uint8_t_u_u (uint8_t _ui1, uint8_t _ui2) { return safe_mod_macro_uint8_t_u_u(_ui1,_ui2); } #define safe_lshift_macro_uint16_t_u_u(left,right) \ (((((unsigned int)(right)) >= sizeof(uint16_t)*CHAR_BIT) \ || (((uint16_t)(left)) > ((UINT16_MAX) >> ((unsigned int)(right))))) \ ? ((uint16_t)(left)) \ : (((uint16_t)(left)) << ((unsigned int)(right)))) static uint16_t safe_lshift_func_uint16_t_u_u(uint16_t _left, unsigned int _right) { return safe_lshift_macro_uint16_t_u_u(_left,_right); } int8_t func_7 (uint8_t p_8); int8_t func_7 (uint8_t p_8) { if (safe_mod_func_uint8_t_u_u (0xC, safe_lshift_func_uint16_t_u_u (p_8, p_8))) { return 0; } return 1; } static inline void platform_main_end(int8_t crc); static inline void platform_main_end(int8_t crc) { asm volatile("cli" "\n\t" "mov r30, %A0" "\n\t" "mov r31, %B0" "\n\t" "break" : : "r" (crc) : "memory" ); } int main (void) { platform_main_end (func_7(1)); return 0; } -- Summary: integer wrong code bug on AVR Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: regehr at cs dot utah dot edu GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: avr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39635
next reply other threads:[~2009-04-04 5:42 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-04-04 5:42 regehr at cs dot utah dot edu [this message] 2009-04-04 5:44 ` [Bug c/39635] " regehr at cs dot utah dot edu 2009-04-07 9:51 ` [Bug c/39635] [avr] integer wrong code bug wvangulik at xs4all dot nl 2009-04-07 13:26 ` wvangulik at xs4all dot nl 2009-04-07 15:19 ` [Bug target/39635] " eric dot weddington at atmel dot com 2009-09-13 16:14 ` hutchinsonandy at aim dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-39635-12544@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).