Re: [HACKERS] static assertions in C++

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] static assertions in C++
Date: 2017-12-11 21:56:46
Message-ID: 463f192b-2adf-5c6f-5798-7813d6be0b80@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/11/17 16:45, Tom Lane wrote:
>> I guess the question is whether we would rather be able to have users
>> continue to use older C++ compilers, or be super picky about static
>> assertions.
>
> Uh, what is this "continue to use" bit? We've never supported
> building the backend with C++ compilers.

The problem is static assertions in inline functions in header files.
We do support using the header files in C++ extensions. But now there
is a problem that if a C++ extension happens to pull in a header file
that has a static assertion, it doesn't compile anymore, but it used to
before the static assertion was introduced.

(Currently, we have very few static assertions in header files, so the
problem is not relevant in practice yet, but the use of both static
assertions and inline functions is clearly expanding.)

> (BTW, why is it that we can't fall back on the negative-width-bitfield
> trick for old g++?)

The complaint is

error: types may not be defined in 'sizeof' expressions

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-12-11 22:12:50 Re: [HACKERS] static assertions in C++
Previous Message Tom Lane 2017-12-11 21:45:51 Re: [HACKERS] static assertions in C++