2

Let's take the following C++ example code:

int main() {
    int a = 0;
    unsigned int b = 1;
    if (a < b) {
        // do stuff
    }
}

this is compiled with

g++ -Wall -O0

and gives the warning

warning: comparison between signed and unsigned integer expressions

as expected.

If I change the types of a and b to short and unsigned short, the compiler warning is gone. Why?

mave117
  • 21
  • 1
  • 2

0 Answers0