if (~sizeof buf < len) {
die();
}
This only works with unsigned values, and there are probably some caveats with width and
promotion rules (portable, nonetheless).
Also, assuming your environment uses linear addressing, and there's no other funny stuff going
on with pointer bits (like the effectively 16 free bits on AMD64--using 48-bit addressing).
if (~(uintptr_t)buf < len) {
die();
}
I believe this should work on Windows and all Unix systems (guaranteed by additional SUSv3
constraints), but I'm not positive.