Re: C aggregate passing (Rust kernel policy)

comex
2025-02-22T05:56:36Z

> On Feb 21, 2025, at 2:13 PM, Bart Van Assche <bvanassche@acm.org> wrote:
>
> Initially, early implementations of std::string may have used CoW or reference counting techniques.

More accurately, you can’t have one without the other. std::string is mutable, so reference counting requires copy-on-write (and of course copy-on-write wouldn’t make sense without multiple references).

> Notably, the C++11 standard explicitly banned CoW for std::string in order to avoid its pitfalls.
> [ ... ]

The C++11 spec doesn’t explicitly say ‘thou shalt not copy-on-write’, but it requires std::string's operator[] to be O(1), which effectively bans it because copying is O(n).

Which forced libstdc++ to break their ABI, since they were using copy-on-write before.