http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50486

             Bug #: 50486
           Summary: No warning at signed -> unsigned casting
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: kir...@shutemov.name


$ cat 1.c
enum e {
        A,
        B,
        C
};

int a(enum e e)
{
        if (e < 0)
                return 1;
        return 0;
}

int b(void)
{
        return a(-1);
}

Since enum e has only positive values GCC states that enum is unsigned and
eliminates the if-check. I can see warning about it with -Wtype-limits.
But GCC generates no warning at a(-1), so it silently casts -1 to unsigned.

Reply via email to