Re: pgsql: Provide overflow safe integer math inline functions.
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-committers@lists.postgresql.org,
Michael Paquier <michael.paquier@gmail.com>
Date: 2017-12-17T01:48:32Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes: > On December 16, 2017 5:31:01 PM PST, Tom Lane <tgl@sss.pgh.pa.us> 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 weird int to ptr cases. Kinda seems like clang links to a different runtime 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
Commits
-
Try harder to detect unavailability of __builtin_mul_overflow(int64).
- c6d21d56f1a9 11.0 landed
-
Try to detect runtime unavailability of __builtin_mul_overflow(int64).
- c04d35f442a8 11.0 landed
-
Fix a number of copy & paste comment errors in common/int.h.
- 11b8f076c02b 11.0 landed
-
Provide overflow safe integer math inline functions.
- 4d6ad31257ad 11.0 cited