avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] wrong code from avr-gcc 4.1.2?


From: John Regehr
Subject: [avr-gcc-list] wrong code from avr-gcc 4.1.2?
Date: Sun, 01 Jun 2008 21:14:18 -0600
User-agent: Thunderbird 2.0.0.14 (X11/20080505)

In the code below, avr-gcc 4.1.2 wants to return 1 from func_1() when compiling at -Os. Specifically I'm compiling like this:

  avr-gcc -fwrapv -Os -mmcu=atmega128 foo.c

I believe the correct answer is 0 (this is what avr-gcc-4.2.2 returns at all optimization levels). I don't think the -fwrapv is relevant here but include it to be on the safe side.

John Regehr



static inline unsigned long int
div_rhs(const long int rhs)
{
    if (rhs == 0) return 1;
    return rhs;
}

unsigned long g_66;
long g_73;

int func_1 (void)
{
  unsigned long l_86 = -1L;
  unsigned long l_93 = -9L;
  if ((l_86 >= g_73) < (1 / div_rhs (l_93)))
    return 1;
  else
    return 0;
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]