4 ms·
> Everyone nods and say you should, and then keep writing code without checks, Well, I would take points off for not checking return values, although TBH my ba
by einpoklum 6y ago
> Everyone nods and say you should, and then keep writing code without checks,
Well, I would take points off for not checking return values, although TBH my basic course did not have file I/O (they would use input and output redirection instead, to keep the programs focused on more fundamental things).
> And while I'm ranting, the same goes for undefined behavior. Of course you shouldn't rely on undefined behavior. Of course of course. But maybe, just a little pointer casting is fine?
That's a trickier subject, because it's not just the hassle of checking return values, it may mean your whole approach to implementing something may go down the drain. Also, it's much less obvious; and compilers don't make an effort to warn you about it; and telling the difference between _undefined_ and _implementation-defined_ behavior is an art which few master (and I'm not even one of those few).
This is entertaining to watch regarding UB:
CppCon 2017: Piotr Padlewski “Undefined Behaviour is awesome!”
https://www.youtube.com/watch?v=ehyHyAIa5so https://www.youtube.com/watch?v=ehyHyAIa5so