[Bug 1822] Cast parameters of lm32_interrupt_* to uint32_t

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Mon Jul 11 12:29:58 UTC 2011


https://www.rtems.org/bugzilla/show_bug.cgi?id=1822

--- Comment #4 from Sebastien Bourdeauducq <sebastien.bourdeauducq at gmail.com> 2011-07-11 07:29:58 CDT ---
Ah, indeed, you are right. I just tried the following program and it prints the
same values for b and c:

int main()
{
    unsigned char a;
    unsigned int b, c;

    a = 0xff;
    b = ~a;
    c = ~((unsigned int)a);
    printf("%08x %08x\n", b, c);
    return 0;
}

I thought that the tilde operator applied to e.g. a char would yield another
char that would only later be cast to integer; but apparently the tilde
operator casts to integer before complementing.

Now you can either add an explicit cast to avoid ambiguities, or take the
position that people should learn the various idiosyncrasies of the C language.

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list