Re: Proposal: Add more compile-time asserts to expose inconsistencies. - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Proposal: Add more compile-time asserts to expose inconsistencies.
Date
Msg-id 8A7F3CC7-F8EA-40B4-8C02-49433B12CF5C@anarazel.de
Whole thread Raw
In response to Re: Proposal: Add more compile-time asserts to expose inconsistencies.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On September 30, 2019 10:20:54 AM PDT, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>Andres Freund <andres@anarazel.de> writes:
>> On 2019-09-19 04:46:27 +0000, Smith, Peter wrote:
>>> In the attached patch example I have defined a new macro
>>> StaticAssertDecl. A typical usage of it is shown in the relpath.c
>>> file.
>
>> I'm in favor of adding that - in fact, when I was working on adding a
>a
>> static_assert wrapper, I was advocating for only supporting compilers
>> that know static_assert, so we can put these in the global scope. The
>> number of compilers that don't support static_assert is pretty small
>> today, especially compared to 2012, when we added these.
>>
>https://www.postgresql.org/message-id/E1TIW1p-0002yE-AY%40gemulon.postgresql.org
>>
>https://www.postgresql.org/message-id/27446.1349024252%40sss.pgh.pa.us
>> Tom, you were arguing for restricting to file scope to get broader
>> compatibility, are you ok with adding a seperate *Decl version?
>
>It could use another look now that we require C99.  I'd be in favor
>of having a decl-level static assert if practical.

What do you think about my proposal further down in the email to rely on extern function declarations to have one
fallbackthat works in the relevant scopes (not in expressions, but we already treat that differently)? Seems to work on
commoncompilers and seems standard conform? 

Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Proposal: Add more compile-time asserts to expose inconsistencies.
Next
From: Tomas Vondra
Date:
Subject: Re: Optimize partial TOAST decompression