C++ Logo

std-discussion

Advanced search

Re: Is [[indeterminate]] not applicable to data members?

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Thu, 13 Mar 2025 16:49:44 +0100
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.

My 2 c,
--
Giuseppe D'Angelo

Received on 2025-03-13 15:49:48