Re: cpluspluscheck complains about use of register

Christoph Berg <myon@debian.org>

From: Christoph Berg <myon@debian.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@postgresql.org, Fabien COELHO <coelho@cri.ensmp.fr>
Date: 2024-02-12T11:03:01Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Remove uses of register due to incompatibility with C++17 and up

Re: Tom Lane
> > I hit this again while porting cplupluscheck to be invoked by meson as
> > well. ISTM that we should just remove the uses of register.
> 
> OK by me.
> 
> > I tried to use -Wregister to keep us honest going forward, but unfortunately
> > it only works with a C++ compiler...
> 
> I think we only really care about stuff that cpluspluscheck would spot,
> so I don't feel a need to mess with the standard compilation flags.

This has started to hurt: postgresql-debversion (a Debian version number
data type written in C++) failed to build against Postgresql <= 15 on
Ubuntu's next LTS release (24.04):

In file included from /usr/include/postgresql/15/server/port/atomics.h:70:
/usr/include/postgresql/15/server/port/atomics/arch-x86.h:143:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  143 |         register char _res = 1;

I managed to work around it by putting `#define register` before
including the PG headers.

Should the removal of "register" be backported to support that better?

Christoph