What is happening is that inclGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);
you are asking at the same time for the name of 5 devices (not to be stored anywhere) and for the number of devices, and this probably confuses the OpenCL implementation, so that num_devices is not properly initialized or getting a bogus value. Try using 0 instead of 5 as third parameter.
The specification is not explicit on this, but I see no reason why num_devices should not be correctly initialized even when num_entries is present, which is why I think this is a bug in the implementation.
Yea, that fixed it.