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

From: "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>
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-05 00:51:18
Message-ID: 201DD0641B056142AC8C6645EC1B5F62014B9DA86E@SYD1217
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

-----Original Message-----
From: Andres Freund <andres(at)anarazel(dot)de> Sent: Tuesday, 3 December 2019 2:56 AM
> +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.

OK. I have no problem to modify all my current assertion messages to your suggested text ("array length mismatch") if you think it is better.

Please correct me if I am wrong, but I didn't think the error message text is of very great significance here because it is a compile-time issue meaning the *only* person who would see the message is the 1 developer who accidentally introduced a bug just moments beforehand. The compile will fail with a source line number, and when the developer sees the StaticAssertDecl at that source line the cause of the error is anyway self-evident by the condition parameter.

Kind Regards
--
Peter Smith
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2019-12-05 00:54:58 Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.
Previous Message Tom Lane 2019-12-04 23:16:14 Re: about allow_system_table_mods and SET STATISTICS