RE: Proposal: Add more compile-time asserts to expose inconsistencies.

From: "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, "andres(at)anarazel(dot)de" <andres(at)anarazel(dot)de>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "peter(dot)eisentraut(at)2ndquadrant(dot)com" <peter(dot)eisentraut(at)2ndquadrant(dot)com>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "ilmari(at)ilmari(dot)org" <ilmari(at)ilmari(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Proposal: Add more compile-time asserts to expose inconsistencies.
Date: 2019-12-20 01:08:47
Message-ID: 201DD0641B056142AC8C6645EC1B5F62014B9FB055@SYD1217
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Michael,

> In short, attached is an updated version of your patch which attempts to solve that. I have tested this with some cplusplus stuff, and GCC for both versions (static_assert is available in GCC >= 6, but a manual change of c.h does the trick).
> I have edited the patch a bit while on it, your assertions did not use project-style grammar, the use of parenthesis was inconsistent (see relpath.c for example), and pgindent has complained a bit.

Thanks for your updates.

~~

Hello Andres,

>> +StaticAssertDecl(lengthof(LockTagTypeNames) == (LOCKTAG_ADVISORY + 1),
>> + "LockTagTypeNames array inconsistency");
>> +
> These error messages strike me as somewhat unhelpful. I'd probably just reword them as "array length mismatch" or something like that.

I updated the most recent patch (_5 from Michael) so it now has your suggested error message rewording.

PSA patch _6

Kind Regards
----
Peter Smith
Fujitsu Australia

Attachment Content-Type Size
ct_asserts_StaticAssertDecl_6.patch application/octet-stream 7.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2019-12-20 01:39:11 Re: How is this possible "publication does not exist"
Previous Message Thomas Munro 2019-12-20 01:06:56 Re: [HACKERS] kqueue