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

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, "Smith, Peter" <peters@fast.au.fujitsu.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "tgl@sss.pgh.pa.us" <tgl@sss.pgh.pa.us>, "ilmari@ilmari.org" <ilmari@ilmari.org>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2019-12-23T03:45:00Z
Lists: pgsql-hackers
On Wed, Dec 04, 2019 at 09:54:47AM -0800, Andres Freund wrote:
> Well, _Static_assert has an error message, so we got to pass
> something. And having something like "array length mismatch", without
> referring again to the variable, doesn't strike me as that bad. We could
> of course just again pass the expression, this time stringified, but
> that doesn't seem an improvement.

Yeah, I would rather keep the second argument.  I think that's also
more helpful as it gives more flexibility to extension authors willing
to make use of it.
--
Michael

Commits

  1. Add declaration-level assertions for compile-time checks

  2. Add support for static assertions in C++