Re: cpluspluscheck complains about use of register

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: cpluspluscheck complains about use of register
Date: 2022-03-09 10:08:57
Message-ID: alpine.DEB.2.22.394.2203091100270.2605400@pseudo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


>>> It seems we should just remove the use of register?
>>
>> I have a vague idea that it was once important to say "register" if
>> you are going to use the variable in an asm snippet that requires it
>> to be in a register. That might be wrong, or it might be obsolete
>> even if once true. We could try taking these out and seeing if the
>> buildfarm complains.
>
> We have several inline asm statements not using register despite using
> variables in a register (e.g. pg_atomic_compare_exchange_u32_impl()), so I
> wouldn't expect a problem with compilers we support.
>
> Should we make configure test for -Wregister? There's at least one additional
> use of register that we'd have to change (pg_regexec).

From a compilation perspective, "register" tells the compiler that you
cannot have a pointer on a variable, i.e. it generates an error if someone
adds something like:

void * p = &register_variable;

Removing the "register" declaration means that such protection would be
removed, and creating such a pointer could reduce drastically compiler
optimization opportunities.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2022-03-09 10:12:01 RE: Column Filtering in Logical Replication
Previous Message torikoshia 2022-03-09 10:04:49 Re: RFC: Logging plan of the running query