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 1mjptA-0004xV-Ka for pgsql-committers@arkaria.postgresql.org; Sun, 07 Nov 2021 21:39:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mjpt9-0004hm-FG for pgsql-committers@arkaria.postgresql.org; Sun, 07 Nov 2021 21:39:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mjpt9-0004hd-8L for pgsql-committers@lists.postgresql.org; Sun, 07 Nov 2021 21:39:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mjpt6-0001Em-Ot for pgsql-committers@lists.postgresql.org; Sun, 07 Nov 2021 21:39:42 +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 1A7LdbVU774859; Sun, 7 Nov 2021 16:39:37 -0500 From: Tom Lane To: Robert Haas cc: Michael Paquier , pgsql-committers Subject: Re: pgsql: Change ThisTimeLineID from a global variable to a local variable In-reply-to: References: <757856.1636305805@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Sun, 07 Nov 2021 15:52:41 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <774857.1636321177.1@sss.pgh.pa.us> Date: Sun, 07 Nov 2021 16:39:37 -0500 Message-ID: <774858.1636321177@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Sun, Nov 7, 2021 at 12:23 PM Tom Lane wrote: >> Yeah. I've seen some older compilers complain about that code before, >> but now there are over a dozen buildfarm members warning about it. >> It's clearly a false positive, since checkPointLoc does get set in >> the read_backup_label()-failure-return code path. I think we've >> seen a few other places where likely-to-be-inlined functions have >> to initialize their result variables to prevent compiler warnings, >> so I stuck an initialization step into read_backup_label in hopes >> of silencing it. > That makes sense, and sorry for not noticing this discussion sooner. > But, I'm a bit confused about what's going on here. Why did we start > getting this complaint only now? AFAICS I didn't change anything about > how checkPointLoc is handled. I think it's pretty clearly a compiler bug. The triggering conditions are obscure, but they seem to have to do with inlining a function that is supposed to initialize some variables but skips doing so in some code paths for which "it shouldn't matter". You'd think that having inlined, the compiler could see that all live code paths initialize the variable ... but sometimes it doesn't see that. Based on this data point, we can speculate that the number of such variables matters, too. Also, as I said, I've seen compilers warn about checkPointLoc before. prairiedog's admittedly-ancient gcc has been doing so for years. regards, tom lane