|From:||ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker )|
|To:||Michael Paquier <michael(at)paquier(dot)xyz>|
|Cc:||"Smith\, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: Proposal: Add more compile-time asserts to expose inconsistencies.|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Wed, Sep 18, 2019 at 06:46:24AM +0000, Smith, Peter wrote:
>> 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.
> For some of them it could help, and we could think about a better
> location for that stuff than an unused routine.
Postgres doesn't seem to have it, but it would be possible to define a
StaticAssertDecl macro that can be used at the file level, outside any
function. See for example Perl's STATIC_ASSERT_DECL:
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law
|Next Message||Fabien COELHO||2019-09-18 17:03:02||Re: pgbench - allow to create partitioned tables|
|Previous Message||Konstantin Knizhnik||2019-09-18 15:38:55||Relation extension lock bottleneck|