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

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: michael(at)paquier(dot)xyz
Cc: ilmari(at)ilmari(dot)org, peters(at)fast(dot)au(dot)fujitsu(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Proposal: Add more compile-time asserts to expose inconsistencies.
Date: 2019-09-19 02:45:02
Message-ID: 20190919.114502.53314118.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 19 Sep 2019 10:07:40 +0900, Michael Paquier <michael(at)paquier(dot)xyz> wrote in <20190919010740(dot)GC22307(at)paquier(dot)xyz>
> On Wed, Sep 18, 2019 at 04:46:30PM +0100, Dagfinn Ilmari Mannsåker wrote:
> > 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:
> >
> > https://github.com/Perl/perl5/blob/v5.30.0/perl.h#L3455-L3488
>
> That sounds like a cleaner alternative. Thanks for the pointer.

The cause for StaticAssertStmt not being usable outside of
functions is enclosing do-while, which is needed to avoid "mixed
declaration" warnings, which we are inhibiting to use as of
now. Therefore just defining another macro defined as just
_Static_assert() works fine.

I don't find an alternative way for the tool chains that don't
have static assertion feature. In the attached diff the macro is
defined as nothing. I don't find a way to warn that the assertion
is ignored.

regards.

Attachment Content-Type Size
define_StaticAssertDecl.patch text/x-patch 2.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-09-19 02:52:04 Re: [HACKERS] [PATCH] pageinspect function to decode infomasks
Previous Message Alexandra Wang 2019-09-19 02:39:41 Re: Zedstore - compressed in-core columnar storage