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: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-09-18T06:46:24Z
Lists: pgsql-hackers
Attachments
- 0001-Add-compile-time-asserts.patch (application/octet-stream) patch 0001
Dear Hackers, I have identified some OSS code where more compile-time asserts could be added. Mostly these are asserting that arrays have the necessary length to accommodate the enums that are used to index into them. In general the code is already commented with warnings such as: * "If you add a new entry, remember to ..." * "When modifying this enum, update the table in ..." * "Display names for enums in ..." * etc. But comments can be accidentally overlooked, so adding the compile-time asserts can help eliminate human error. Please refer to the attached patch. Kind Regards, Peter Smith --- Fujitsu Australia
Commits
-
Add declaration-level assertions for compile-time checks
- f1f10a1ba9e1 13.0 landed
-
Add support for static assertions in C++
- a2c8e5cfdb9d 11.0 cited