From 21ad1b2419ec988d286d15206c133f729c0a313e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Kr=C3=BCgler?=
Date: Sat, 14 Oct 2023 15:40:27 +0200
Subject: [PATCH] =?UTF-8?q?New=20issue=20from=20Peter=20Sommerlad:=20"basi?=
=?UTF-8?q?c=5Fstringbuf::str()&&=20should=20enforce=20=F0=9D=92=AA(1)"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
xml/issue3992.xml | 69 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 xml/issue3992.xml
diff --git a/xml/issue3992.xml b/xml/issue3992.xml
new file mode 100644
index 0000000000..6aadead913
--- /dev/null
+++ b/xml/issue3992.xml
@@ -0,0 +1,69 @@
+
+
+
+
+basic_stringbuf::str()&& should enforce 𝒪(1)
+
+Peter Sommerlad
+05 Oct 2023
+99
+
+
+
+Recent discussions on llvm-64644
+came to the conclusion that basic_stringbuf() && introduced by
+might just copy the underlying buffer into a string object and not actually move the allocated space.
+While the wording tried to encourage that, especially with the postcondition that the buffer must
+be empty afterwards, it failed to specify that the move is never a copy.
+
+I suggest to amend the specification to enforce implementors to do the 𝒪(1) thing.
+There might be ABI issues for those who still copy.
+
+Some investigation into p.16 and
+shows that a basic_string as a standard container should move with 𝒪(1).
+
+Unfortunately, we cannot say
+
+
+str().data() == buf.data() before calling str()
+
+
+as a postcondition due to SSO. Maybe a note could be added to eliminate the confusion.
+
+
+
+
+
+This wording is relative to .
+
+
+
+
+Modify as indicated:
+
+
+
+basic_string<charT, traits, Allocator> str() &&;
+
+
+
+-9- Postconditions: The underlying character sequence buf is empty and pbase(), pptr(),
+epptr(), eback(), gptr(), and egptr() are initialized as if by calling
+init_buf_ptrs() with an empty buf.
+
+-10- Returns: A basic_string<charT, traits, Allocator> object move constructed from the
+basic_stringbuf's underlying character sequence in buf. This can be achieved by first adjusting buf
+to have the same content as view().
+
+[Note: — require the move construction of the return
+value to be 𝒪(1) end note]
+
+
+
+
+
+
+
+
+
+