3 ms·
Experience tells us that this idea doesn't work so well in practice without a compiler yelling if you don't do it.
by sgift 9y ago
Experience tells us that this idea doesn't work so well in practice without a compiler yelling if you don't do it.
- megous 9y agoCompiler doesn't yell, because it's unnecessary in most cases. My experience is that huge amount of C code running on my computer had exactly zero issues like this today. It has been working perfectly fine. I run GNOME which uses a paradigm of checking all inputs to a function on entry via g_return(_val)_if_fail(assertion_expression). It helps the programmer do the right thing when it comes to using APIs that are disallowing NULL input. Two days ago, the code on my workstation hit one of those "assertions": Sep 26 23:40:31 core transmission-gt[1084]: g_file_test: assertion 'filename != NULL' failed No oops in the kernel recently. Millions of lines of desktop and kernel code, and one failed assertion in two days for using NULL incorrectly in the API. So unless your standard is absolute perfection, it works fine as is.