This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
In the code below, g_52 should end up being 5. At -O1, avr-gcc-4.5.0 puts 1 into this variable. Verified using AVR Studio. 4.3.3 also seems to have this bug. regehr@john-home:~/volatile/work0/014255$ avr-gcc -O1 small.c -mmcu=atmega128 -o small.elf regehr@john-home:~/volatile/work0/014255$ 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:~/volatile/work0/014255$ cat small.c #include <stdint.h> #include <limits.h> #define safe_add_macro_int8_t_s_s(si1,si2) \ ((((((int8_t)(si1))>((int8_t)0)) && (((int8_t)(si2))>((int8_t)0)) && (((int8_t)(si1)) > ((INT8_MAX)-((int8_t)(si2))))) \ || ((((int8_t)(si1))<((int8_t)0)) && (((int8_t)(si2))<((int8_t)0)) && (((int8_t)(si1)) < ((INT8_MIN)-((int8_t)(si2)))))) \ ? ((int8_t)(si1)) \ : (((int8_t)(si1)) + ((int8_t)(si2))) \ ) static int8_t safe_add_func_int8_t_s_s(int8_t _si1, int8_t _si2) { return safe_add_macro_int8_t_s_s(_si1,_si2); } uint8_t g_52; void func_1 (void); void func_1 (void) { uint64_t l_116; for (l_116 = 0; l_116 < 13; l_116 = safe_add_func_int8_t_s_s (l_116, 3)) { g_52++; } } static inline void platform_main_end(uint32_t crc); static inline void platform_main_end(uint32_t crc) { uint16_t crc16 = crc ^ (crc >> 16); asm volatile("cli" "\n\t" "mov r30, %A0" "\n\t" "mov r31, %B0" "\n\t" "break" : : "r" (crc16) : "memory" ); } int main (void) { func_1 (); platform_main_end (g_52); return 0; }
At -O2, -O3, -Os g_52 contains the value 5 while in -O1 it is 1.It is confirmed.
(In reply to comment #1) > At -O2, -O3, -Os g_52 contains the value 5 while in -O1 it is 1.It is > confirmed. > Hi Abnikant, What version did you use to confirm this bug?
Subject: RE: [avr] loop bug Hi Eric, Version is (avr-gcc )4.3.2. -----Original Message----- From: eric dot weddington at atmel dot com [mailto:gcc-bugzilla@gcc.gnu.org] Sent: Monday, August 17, 2009 5:26 PM To: Singh, Abnikant Subject: [Bug target/39633] [avr] loop bug ------- Comment #2 from eric dot weddington at atmel dot com 2009-08-17 11:56 ------- (In reply to comment #1) > At -O2, -O3, -Os g_52 contains the value 5 while in -O1 it is 1.It is > confirmed. > Hi Abnikant, What version did you use to confirm this bug?
4.3.2