[Bug c/35957] New: static return value type checking, no warning issued

clemens dot kol at gmx dot at gcc-bugzilla@gcc.gnu.org
Wed Apr 16 11:18:00 GMT 2008


I hope this does not conflict with the C-standard, but why does the following
code not issue a warning about the return value of 'someFunction'?

#include <stdio.h>

unsigned int someFunction() { return 0xbadc0de; }
void someOtherFunction(unsigned char in) { printf("0x%x\n", in); }

int main(int argc, char **argv)
{
        unsigned char x;
        unsigned int y;

        x = someFunction();
        printf("0x%x\n", x);

        y = 0xbadc0de;
        someOtherFunction(y);

        return 0;
}

The return value is correctly cast to a char, but shouldn't the compiler
complain?


-- 
           Summary: static return value type checking, no warning issued
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: clemens dot kol at gmx dot at


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



More information about the Gcc-bugs mailing list