Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u5Azx-00DQkd-3y for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 22:12:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u5Azu-006iX8-UR for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 22:12:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u5Azu-006iX0-KT for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 22:12:47 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u5Azs-000RGi-36 for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 22:12:46 +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 53GMCik82078512; Wed, 16 Apr 2025 18:12:44 -0400 From: Tom Lane To: Daniel Gustafsson cc: pgsql-hackers@lists.postgresql.org Subject: Re: jsonapi: scary new warnings with LTO enabled In-reply-to: <0A3CF5C4-9947-42E3-89A9-34FCF7BA95BA@yesql.se> References: <2074634.1744839761@sss.pgh.pa.us> <0A3CF5C4-9947-42E3-89A9-34FCF7BA95BA@yesql.se> Comments: In-reply-to Daniel Gustafsson message dated "Wed, 16 Apr 2025 23:52:42 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2078510.1744841564.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 16 Apr 2025 18:12:44 -0400 Message-ID: <2078511.1744841564@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: >> On 16 Apr 2025, at 23:42, Tom Lane wrote: >> I'm not sure >> how other than giving up on stack allocation of JsonLexContexts, >> though, especially if we consider the jsonapi API frozen. But seeing >> that there are only three such call sites and none of them seem in the >> least performance-critical, maybe we should just do that? > I can't see any other option really, and there is no performance angle r= eally > so that should be safe. Since I committed at least one of these, let me= know > if you want me to tackle it. The only alternative I can see that might stop the warning is if we can find a way to make it clearer to the optimizer that the FREE() isn't reached. But I'm not sure about a trustworthy way to make that happen. Maybe it'd work to change the signature of freeJsonLexContext (or perhaps better, add a separate entry point) so that the caller is passing a bool constant that controls whether to free the struct. We could have an Assert that compares that to the state of the JSONLEX_FREE_STRUCT flag to catch mistakes. This seems kind of messy though. regards, tom lane