sizeof
generates a size_t
which is always positive. You are comparing it with -1
which is probably promoted in size_t
which gave you a HUGE number, most likely greater than the size of an int.
To make sure of it, try this:
printf("%zu\n", sizeof(int));
printf("%zu\n", (size_t)(-1));
[EDIT]: Following comments (some have been removed), I precise indeed that sizeof
is an operator, not a function.