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

Smith, Peter <peters@fast.au.fujitsu.com>

From: "Smith, Peter" <peters@fast.au.fujitsu.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, "andres@anarazel.de" <andres@anarazel.de>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "peter.eisentraut@2ndquadrant.com" <peter.eisentraut@2ndquadrant.com>, "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-11-27T12:23:33Z
Lists: pgsql-hackers

Attachments

> It seems to me that there is a good point to be consistent with the treatment of StaticAssertStmt and StaticAssertExpr in c.h, which have fallback implementations in *all* the configurations supported.

Consistency is good, but:

* That is beyond the scope for what I wanted my patch to achieve; my use-cases are C code only

* It is too risky for me to simply cut/paste my C version of StaticAssertDecl and hope it will work OK for C++. It needs lots of testing because there seems evidence that bad things can happen. E.g. Peter Eisentraut wrote "if you're asking, why is the fallback implementation in C++ different from the one in C, then that's because the C variant didn't work in C++."

~

I am happy if somebody else with more ability to test C++ properly wants to add the __cplusplus variant of the new macro.

Meanwhile, I've attached latest re-based version of this patch.

Kind Regards.
--
Peter Smith
Fujitsu Australia

Commits

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

  2. Add support for static assertions in C++