Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » AVR-GCC
  • » [avr] result of char promotion comes out of CHAR_MIN/MAX [RSS Feed]

#1 March 19, 2008 07:03:19

Dmitry K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr] result of char promotion comes out of CHAR_MIN/MAX


/* The next program is aborted with avr-gcc 4.1.2, 4.2.3, 4.3.0:
result of char promotion comes out of CHAR_MIN/MAX.
Options: -W -Wall -Os
Know to work:
3.3.6, 3.4.6 - good code
4.0.4 - correct, but not the best
4.1.2, 4.2.3, 4.3.0 - without optimization only
*/

#include <limits.h>

void abort (void);
void exit (int);

void foo (int i)
{
static int n;
if (i < CHAR_MIN || i > CHAR_MAX)
abort ();
if (++n > 1000)
exit (0);
}

int main ()
{
char c;
for (c = 0; ; c++) foo (c);
}



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

  • Root
  • » AVR-GCC
  • » [avr] result of char promotion comes out of CHAR_MIN/MAX [RSS Feed]

Board footer

Moderator control

Enjoy the 16th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support