Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQO4H-0006rY-Cz for pgsql-committers@arkaria.postgresql.org; Sun, 17 Dec 2017 01:48:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQO4G-0007wJ-Nr for pgsql-committers@arkaria.postgresql.org; Sun, 17 Dec 2017 01:48:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eQO4G-0007w8-Cs for pgsql-committers@lists.postgresql.org; Sun, 17 Dec 2017 01:48:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eQO4D-0003bM-8q for pgsql-committers@lists.postgresql.org; Sun, 17 Dec 2017 01:48:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vBH1mWg1023538; Sat, 16 Dec 2017 20:48:32 -0500 From: Tom Lane To: Andres Freund cc: pgsql-committers@lists.postgresql.org, Michael Paquier Subject: Re: pgsql: Provide overflow safe integer math inline functions. In-reply-to: <99F06D02-BB7E-40F1-93BE-7113713F1AC0@anarazel.de> References: <20171213213754.pydkyjs6bt2hvsdb@alap3.anarazel.de> <20171217003207.3myeahkbsm63kbvl@alap3.anarazel.de> <22109.1513474261@sss.pgh.pa.us> <99F06D02-BB7E-40F1-93BE-7113713F1AC0@anarazel.de> Comments: In-reply-to Andres Freund message dated "Sat, 16 Dec 2017 17:35:05 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23536.1513475312.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 16 Dec 2017 20:48:32 -0500 Message-ID: <23537.1513475312@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On December 16, 2017 5:31:01 PM PST, Tom Lane wrote: >> The committed test looks quite broken to me: it's missing some & >> operators. Not sure how that translates into failing to fail the >> configure test, > Hm, true. As you say, it doesn't explain the problem though, it's just w= eird int to ptr cases. Kinda seems like clang links to a different runtim= e during the configure tests than what's used for postgres... What I'm thinking is that that somehow prevents the "volatile" from having any effect. On my laptop (recent Apple clang), the function call certainly does seem to get optimized away with the test-as-committed... Oh! It seems to get optimized away with my "volatile" version too. I think the real issue, or part of it, is that you need to assign the result to a global variable, not a local one, so that the compiler doesn't decide it can forget the whole thing. And maybe store the bool result somewhere, too. Marking the result and bool-result variables as volatile might be an OK substitute for making them global. But the global way is what we've done in older configure test programs. regards, tom lane