Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTobJ-0007Pn-7Y for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Oct 2020 15:58:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kTobH-00025N-6f for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Oct 2020 15:58:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTobG-00025G-Vy for pgsql-hackers@lists.postgresql.org; Sat, 17 Oct 2020 15:58:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTobF-0000g4-06 for pgsql-hackers@postgresql.org; Sat, 17 Oct 2020 15:58:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09HFwQlh118218; Sat, 17 Oct 2020 11:58:27 -0400 From: Tom Lane To: Peter Eisentraut cc: pgsql-hackers Subject: Re: warn_unused_results In-reply-to: References: Comments: In-reply-to Peter Eisentraut message dated "Sat, 17 Oct 2020 08:57:51 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <118216.1602950306.1@sss.pgh.pa.us> Date: Sat, 17 Oct 2020 11:58:26 -0400 Message-ID: <118217.1602950306@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut 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