Re: Proposal: Add more compile-time asserts to expose inconsistencies.
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: peters@fast.au.fujitsu.com, andres@anarazel.de, pgsql-hackers@lists.postgresql.org, peter.eisentraut@2ndquadrant.com, tgl@sss.pgh.pa.us, ilmari@ilmari.org, pgsql-hackers@postgresql.org
Date: 2020-01-31T05:46:16Z
Lists: pgsql-hackers
On Fri, Jan 31, 2020 at 02:15:42PM +0900, Kyotaro Horiguchi wrote: > As a cross check, it cleanly applied and worked as expected. The > fallback definition of StaticAssertDecl for C worked for gcc 8.3. Thanks for the review. > - * Macros to support compile-time assertion checks. > + * Macros to support compile-time and declaration assertion checks. > > All the StaticAssert things check compile-time assertion. I think > that the name StaticAssertDecl doesn't mean "declaration assertion", > but means "static assertion as a declaration". Is the change needed? Hmm. Yeah, that sounds right. > - * If the "condition" (a compile-time-constant expression) evaluates to false, > - * throw a compile error using the "errmessage" (a string literal). > + * If the "condition" (a compile-time-constant or declaration expression) > + * evaluates to false, throw a compile error using the "errmessage" (a > + * string literal). > > I'm not sure what the "declaration expression" here means. I think > the term generally means "a variable declaration in expressions", > something like "r = y * (int x = blah)". In that sense, the parameter > for StaticAssertDecl is just a compile-time constant expression. Is it > a right rewrite? Actually, thinking more about it, I'd rather remove this part as well, keeping only the change in the third paragraph of this comment block. -- 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