From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: warn_unused_results
Date: Sat, 17 Oct 2020 11:58:26 -0400
Message-ID: <118217.1602950306@sss.pgh.pa.us> (raw)
In-Reply-To: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com>
References: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter.eisentraut@2ndquadrant.com
Subject: Re: warn_unused_results
In-Reply-To: <118217.1602950306@sss.pgh.pa.us>
References: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com> <118217.1602950306@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox