[libcxx-commits] [libcxx] [libc++] Fix iostream size ABI break (PR #185839)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 11 07:28:28 PDT 2026
================
@@ -16,21 +16,29 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class T>
+union stream {
+ constexpr stream() {}
+ stream(const stream&) = delete;
+ stream& operator=(const stream&) = delete;
+ constexpr ~stream() {}
+
+ T value;
+};
+
template <class StreamT, class BufferT>
union stream_data {
constexpr stream_data() {}
constexpr ~stream_data() {}
struct {
- // The stream has to be the first element, since that's referenced by the stream declarations in <iostream>
- StreamT stream;
BufferT buffer;
mbstate_t mb;
};
- void init(FILE* stdstream) {
+ void init(FILE* stdstream, stream<StreamT>& stream) {
mb = {};
std::construct_at(&buffer, stdstream, &mb);
- std::construct_at(&stream, &buffer);
+ std::construct_at(&stream.value, &buffer);
}
----------------
ldionne wrote:
Let's make this a free function and pass the `FILE*` and both the stream data and the actual stream object explicitly:
```
template <class StreamT, class BufferT>
void init_streams(FILE*, stream<StreamT>&, stream_data<StreamT, BufferT>&);
```
https://github.com/llvm/llvm-project/pull/185839
More information about the libcxx-commits
mailing list