When I try to compile the following program in C ++ using the Visual Studio 2010 C ++ compiler (X86) with the warning level / W 4 enabled, I get a warning about a mismatch with the signature / unsigned in the marked line.
#include <cstdio>
#include <cstdint>
#include <cstddef>
int main(int argc, char **argv)
{
size_t idx = 42;
uint8_t bytesCount = 20;
if (bytesCount + 1 == idx)
{
printf("Hello World\n");
}
if (bytesCount == idx)
{
printf("Hello World\n");
}
}
This bothers me as I only use unsigned types. Since comparison
bytesCount == idx
doesnβt cause such a warning, probably this is due to some strange implicit conversation that is taking place here.
Thus: what is the reason why I receive this warning and by what rules does this conversation occur (if this is the reason)?
Nubok source
share