Date: Fri, 14 Mar 2025 14:56:41 +0800
On Thu, 13 Mar 2025 at 23:49, Giuseppe D'Angelo via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> Hello,
>
> Il 11/03/25 15:04, Yongwei Wu via Std-Discussion ha scritto:
> > I wrote a BigFixedString for test purposes, and google-benchmarked it.
> > Two versions are posted online:
> >
> > https://quick-bench.com/q/9QkL9cSkqHSi2pb5A-TTkglbaDU
> > https://quick-bench.com/q/MmE9IwFaXqjz_gFnEmSK8s3qFrA
> >
> > The difference is that one has a member `char buffer_[128];`, and the
> > other `char buffer_[128]{};`. Of course, the uninitialized data are
> > never read.
>
> I think there's still a misunderstanding: C++26's EB is *not* requiring
> an implementation to fill your `char buffer_[128]` with some values, and
> make you pay for a performance penalty there (like the one you observe
> if you manually initialize that byte buffer in the second link). In
> fact, why should an implementation fill anything? Returning whatever
> value is found in the memory (stack/heap) backing `buffer_` is a valid
> form of EB.
P2795 was adopted last year, which said:
Default-initialization of an automatic-storage object initializes the
object with a fixed value defined by the implementation....
Also the standard draft ([basic.indet]):
otherwise, the bytes have erroneous values, where each value is
determined by the implementation independently of the state of the
program.
Notice "independently of the state of the program".
So my understanding is that a conforming implementation needs to fill
the buffer (and cause a performance penalty).
<std-discussion_at_[hidden]> wrote:
>
> Hello,
>
> Il 11/03/25 15:04, Yongwei Wu via Std-Discussion ha scritto:
> > I wrote a BigFixedString for test purposes, and google-benchmarked it.
> > Two versions are posted online:
> >
> > https://quick-bench.com/q/9QkL9cSkqHSi2pb5A-TTkglbaDU
> > https://quick-bench.com/q/MmE9IwFaXqjz_gFnEmSK8s3qFrA
> >
> > The difference is that one has a member `char buffer_[128];`, and the
> > other `char buffer_[128]{};`. Of course, the uninitialized data are
> > never read.
>
> I think there's still a misunderstanding: C++26's EB is *not* requiring
> an implementation to fill your `char buffer_[128]` with some values, and
> make you pay for a performance penalty there (like the one you observe
> if you manually initialize that byte buffer in the second link). In
> fact, why should an implementation fill anything? Returning whatever
> value is found in the memory (stack/heap) backing `buffer_` is a valid
> form of EB.
P2795 was adopted last year, which said:
Default-initialization of an automatic-storage object initializes the
object with a fixed value defined by the implementation....
Also the standard draft ([basic.indet]):
otherwise, the bytes have erroneous values, where each value is
determined by the implementation independently of the state of the
program.
Notice "independently of the state of the program".
So my understanding is that a conforming implementation needs to fill
the buffer (and cause a performance penalty).
-- Yongwei Wu URL: http://wyw.dcweb.cn/
Received on 2025-03-14 06:56:57