On the Effectiveness of nonnull: Difference between revisions

No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
I add [https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html annotations] to my [[C]] programs pretty religiously, making most frequent use of:
I add [https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html annotations] to my [[C]] programs pretty religiously, making most frequent use of:


* <tt>const</tt> and <tt>pure</tt> -- facilitate subexpression hoisting and memoization
* <tt>const</tt> and <tt>pure</tt> -- facilitate hoisting and memoization
* <tt>malloc</tt> -- helps aliasing analysis and warning generation
* <tt>malloc</tt> -- helps aliasing analysis and warning generation
* <tt>warn_unused_result</tt> -- warning generation
* <tt>warn_unused_result</tt> -- warning generation
Line 13: Line 13:
* <tt>sentinel</tt> in the unfortunate situations where it's applicable (did you really need varargs there? that's not how we raised you, son)
* <tt>sentinel</tt> in the unfortunate situations where it's applicable (did you really need varargs there? that's not how we raised you, son)


and of course the ubiquitous <code>visibility("default")</code> (roughly) ala Microsoft's <tt>__declspec(dllexport)</tt>, which you ought be diligently employing on your shared libraries as [https://www.akkadia.org/drepper/dsohowto.pdf mr. drepper] taught you.
and of course the ubiquitous <tt>visibility("default")</tt> (roughly) ala Microsoft's <tt>__declspec(dllexport)</tt>, which you ought be diligently employing on your shared libraries as [https://www.akkadia.org/drepper/dsohowto.pdf mr. drepper] taught you.


<tt>access</tt> lets you get fine-grained, Ada-like controls on your variable access types, but if i were writing Ada i'd be fucking with <tt>gnat</tt> and working for Northrop Grumman and questioning my life choices.
<tt>access</tt> lets you get fine-grained, Ada-like controls on your variable access types, but if i were writing Ada i'd be fucking with <tt>gnat</tt> and working for Northrop Grumman and questioning my life choices.
Line 70: Line 70:
and thus the inevitable "what? oh fuck what is this. no i just assigned to <tt>buf</tt>, you dumbass compiler, it could be <tt>NULL</tt> now, computer piece of shit, oh wait no fuck me in the ass, i assigned to <tt>*buf</tt> and checked <tt>buf</tt> like a witless simpleton asshole, fuck me in the ass twice, awww fuck piece of shit brain, thank you compiler you're a good compiler here's some more page cache, awww look at you chomping those pages you're my only friend, compiler."
and thus the inevitable "what? oh fuck what is this. no i just assigned to <tt>buf</tt>, you dumbass compiler, it could be <tt>NULL</tt> now, computer piece of shit, oh wait no fuck me in the ass, i assigned to <tt>*buf</tt> and checked <tt>buf</tt> like a witless simpleton asshole, fuck me in the ass twice, awww fuck piece of shit brain, thank you compiler you're a good compiler here's some more page cache, awww look at you chomping those pages you're my only friend, compiler."


'''next: "[[Four_questions_for_a_Wednesday|four questions for a wednesday]]" 2021-10-13'''
ps i ended up getting rid of the copy when i fixed this, too. w00t! =]
 
'''previously: "[[Four_questions_for_a_Wednesday|four questions for a wednesday]]" 2021-10-13'''


[[Category:Blog]]
[[Category:Blog]]