Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Date: 2022-08-11 16:59:33
Message-ID: CAEudQApjWmVbhgzeKnCVnodrYr-c6n-tn+Bx=8BuY0O5GZ5LUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em qui., 11 de ago. de 2022 às 09:23, Julien Rouhaud <rjuju123(at)gmail(dot)com>
escreveu:

> On Thu, Aug 11, 2022 at 08:51:53AM -0300, Ranier Vilela wrote:
> > Em qui., 11 de ago. de 2022 às 08:48, Alvaro Herrera <
> > alvherre(at)alvh(dot)no-ip(dot)org> escreveu:
> >
> > > On 2022-Aug-11, Ranier Vilela wrote:
> > >
> > > > According to:
> > > > https://interrupt.memfault.com/blog/c-struct-padding-initialization
> > >
> > Did you see the Strategy 3 table, { 0 } ?
>
> It explicitly shows that at least Ubuntu clang version 13.0.0-2 with -01
> doesn't do anything about the padding bytes (and that's after testing only
> 2
> different compilers). Even if those compilers didn't show any problem, we
> still couldn't rely on an undefined behavior and assume that no other
> compilers
> behave differently.
>
Yeah, although not a problem in the main current compilers clang, gcc and
msvc,
it seems that this cannot be changed.
Being an undefined behavior, filling structures with holes, it seems to me
that you should always use MemSet or memset.
Since even a current structure without holes could be changed in the future
and become a bug.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-08-11 17:06:35 Re: tests and meson - test names and file locations
Previous Message vignesh C 2022-08-11 16:36:38 Re: hash_xlog_split_allocate_page: failed to acquire cleanup lock