4 ms·
Yes, exactly. Nobody should be surprised that calling `strlen(NULL)` crashes. Checking for NULL at the top of strlen() would be stupid, which is why it doesn't
by jcalvinowens 3y ago
Yes, exactly. Nobody should be surprised that calling `strlen(NULL)` crashes. Checking for NULL at the top of strlen() would be stupid, which is why it doesn't do that. I've seen a lot of so-called "enterprise" code does that, and it's absolutely idiotic.
- UncleMeat 3y agoOkay. But that's totally unrelated to my original point, which is that we are already very used to functions that do not accept the full domain of a given type. "I don't accept nullptr" is not too fundamentally different from "I don't accept "0x8000..."
- kazinator 3y ago"I don't accept {nullptr, 0x8000}" is fundamentally different from "{nullptr, 0x8000} is a trap representation". If it's a trap representation, you can't even pass it to me so that I could accept or reject it.