https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119179

Barry Revzin <barry.revzin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |barry.revzin at gmail dot com

--- Comment #5 from Barry Revzin <barry.revzin at gmail dot com> ---
I think it is extremely important to support [[gnu::uninitialized]] /
[[indeterminate]] on non-static data members and I have a WG21 paper on this
(https://brevzin.github.io/cpp_proposals/4424_indeterminate_nsdms/p4424r0.html).
 

Here is a PR I opened into fmtlib yesterday:
https://github.com/fmtlib/fmt/pull/5050. The C++26 default of zeroing buffers
leads to a lot of overhead in {fmt}, because a lot of the formatting paths use
fmt::memory_buffer which has an internal 500 byte array. Zeroing it is totally
unnecessary, but I can't just mark that array [[indeterminate]], so instead I
have to mark every use of that buffer. Which that PR does:

* 41 variables of type memory_buffer (or basic_memory_buffer or wmemory_buffer)
* 11 variables of type counting_buffer or iterator_buffer (same idea, they have
a T[256] data member)

But that's enough, because have to go wider: there are 4 variables of type
bigint and 2 variables of a utf conversion type, those have a member
memory_buffer. So that's declaring a variable that has a member that has a
member that needs to be uninitialized for performance reasons. This doesn't
scale very well. 

If memory_buffer could mark its own buffer [[indeterminate]], those 59 variable
attributes would go away and the PR would've just added one on the data member.
And also the dozen or so bespoke char arrays here and there, but those are
really what we are thinking of when we think of [[indeterminate]] variables...
not the memory_buffer case. 

The same is true for a lot of our internal types as well — they have some
buffer implementation detail that wants to remain uninitialized, but cannot be.

Reply via email to