Re: warn_unused_results
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-10-17T15:58:26Z
Lists: pgsql-hackers
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes: > Forgetting to assign the return value of list APIs such as lappend() is > a perennial favorite. The compiler can help point out such mistakes. > GCC has an attribute warn_unused_results. Also C++ has standardized > this under the name "nodiscard", and C has a proposal to do the same > [0]. In my patch I call the symbol pg_nodiscard, so that perhaps in a > distant future one only has to do s/pg_nodiscard/nodiscard/ or something > similar. Also, the name is short enough that it doesn't mess up the > formatting of function declarations too much. +1 in principle (I've not read the patch in detail); but I wonder what pgindent does with these added keywords. regards, tom lane
Commits
-
Add pg_nodiscard decorations to some functions
- a378ba49a5cf 14.0 landed
-
Add pg_nodiscard function declaration specifier
- c617aea6acdd 14.0 landed
-
Fix cases of discarding result from list API functions
- c77f6f50e418 14.0 landed