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

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

Re: [avr-gcc-list] [Bug target/35634] New: [avr] result of char promotio


From: Paulo Marques
Subject: Re: [avr-gcc-list] [Bug target/35634] New: [avr] result of char promotion comes out of CHAR_MIN/MAX
Date: Wed, 19 Mar 2008 12:17:59 +0000
User-agent: Thunderbird 1.5.0.14 (X11/20071210)

Dmitry K. wrote:
[...]
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);
}

Is this strictly wrong, from the C definition point of view?

I know that signed overflow is "undefined". How does this test case interacts with -fwrapv and -fno-strict-overflow?

For those unaware of signed overflow issues, there is a nice sum up here:

http://www.airs.com/blog/archives/120

I know that turning "undefined" into an "out of range" result is ugly, but so is signed overflow....

--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com

"...so she told me it was either her or the ham radio, over."




reply via email to

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