On Mon, 1 May 2023 at 21:04, Jonathan Wakely wrote: > > > On Mon, 1 May 2023 at 08:06, Kefu Chai via Libstdc++ < > libstdc++@gcc.gnu.org> wrote: > >> This patch fixes the false alarm when performing the check introduced by >> bf78b43873b0b7e8f9a430df38749b8b61f9c9b8 . A minimal reproducer can be >> found at https://godbolt.org/z/7q4nG68xn >> >> I am pasting the reproducer here just in case: >> >> #include >> #include >> #include >> >> int main() { >> unsigned char buf[sizeof(std::string)] ; >> std::memset(buf, 0xff, sizeof(buf)); >> const char s[] = "1234567890abcdefg"; >> std::istringstream in{s}; >> std::istreambuf_iterator it{in}, end; >> auto* p = new (buf) std::string(it, end); >> return 0; >> } >> >> Tested on x86_64-pc-linux-gnu, with "make check-target-libstdc++-v3". >> Would be great if this change can be included in thunk, 13.2 and 12 >> branches. >> > > The bf78b43873b0b7e8f9a430df38749b8b61f9c9b8 change isn't on the gcc-12 > branch. > Oh wait, yes it is - I was thinking of another change that I didn't backport, sorry. > > >> Kefu Chai (1): >> libstdc++: Set _M_string_length before calling _M_dispose() >> >> libstdc++-v3/include/bits/basic_string.tcc | 1 + >> 1 file changed, 1 insertion(+) >> >> -- >> 2.40.1 >> >>