From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org,Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>,"Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>,Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>,PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: Add more compile-time asserts to expose inconsistencies. |
Date: | 2019-10-27 01:02:46 |
Message-ID: | 503D84B3-6F1C-46FF-8843-203B04897A81@anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On October 26, 2019 6:06:07 AM PDT, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>On 2019-10-10 00:52, Smith, Peter wrote:
>> I liked your idea of using an extern function declaration for
>implementing the file-scope compile-time asserts. AFAIK it is valid
>standard C.
>>
>> Thank you for the useful link to that compiler explorer. I tried many
>scenarios of the new StaticAssertDecl and all seemed to work ok.
>> https://godbolt.org/z/fDrmXi
>>
>> The patch has been updated accordingly. All assertions identified in
>the original post are now adjacent the global variables they are
>asserting.
>>
>
>The problem with this implementation is that you get a crappy error
>message when the assertion fails, namely something like:
>
>../../../../src/include/c.h:862:84: error: size of array
>'static_assert_failure' is negative
My proposal for this really was just to use this as a fallback for when static assert isn't available. Which in turn I was just suggesting because Tom wanted a fallback.
>Ideally, the implementation should end up calling _Static_assert()
>somehow, so that we get the compiler's native error message.
>
>We could do a configure check for whether _Static_assert() works at
>file
>scope. I don't know what the support for that is, but it seems to work
>in gcc and clang.
I think it should work everywhere that has static assert. So we should need a separate configure check.
Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2019-10-27 04:58:50 | Re: Fix of fake unlogged LSN initialization |
Previous Message | Andres Freund | 2019-10-26 23:21:47 | Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM' |