Re: Proposal: Add more compile-time asserts to expose inconsistencies.
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: "Smith, Peter" <peters@fast.au.fujitsu.com>
Cc: "andres@anarazel.de" <andres@anarazel.de>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, "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: 2020-01-31T02:47:01Z
Lists: pgsql-hackers
Attachments
- 0001-Add-declaration-level-assertions.patch (text/x-diff) patch 0001
- 0002-Refactor-assertion-definitions-in-c.h.patch (text/x-diff) patch 0002
On Tue, Dec 24, 2019 at 02:47:29PM +0900, Michael Paquier wrote: > I am still seeing that a couple of points need an extra lookup: > - Addition of a Decl() in at least one header of the core code. I agree with the addition of Decl() definition in a header, and could not think about something better than one for bufpage.h for the all-zero check case, so I went with that. Attached is a 0001 which adds the definition for StaticAssertDecl() for C and C++ for all code paths. If there are no objections, I would like to commit this version. There is no fancy refactoring in it, and small progress is better than no progress. I have also reworked the comments in the patch, and did some testing on Windows. > - Perhaps unifying the fallback implementation between C and C++, with > a closer lookup in particular at StaticAssertStmt() and StaticAssertExpr(). Seeing nothing happening on this side. I took a shot at all that, and I have hacked my way through it with 0002 which is an attempt to unify the fallback implementation for C and C++. This is not fully baked yet, and it is perhaps a matter of taste if this makes the code more readable or not. I think it does, because it reduces the parts dedicated to assertion definitions from four to three. Anyway, let's discuss about that. -- Michael
Commits
-
Add declaration-level assertions for compile-time checks
- f1f10a1ba9e1 13.0 landed
-
Add support for static assertions in C++
- a2c8e5cfdb9d 11.0 cited