The data type of value provided by sizeof is size_t which is (in most machines) an unsigned int/long, therefore, when you compare it with -1, -1 is type promoted to unsigned which then becomes 0xFFF.. , which is the largest value that datatype can hold, therefore your comparison fails.