Michael137 wrote:

> > But libc++ and libstdc++ print it as "abcd" (which seems like the more 
> > correct thing to do?)
> 
> I'm not so sure about that. std::string has a separate length field and it 
> can contain embedded nul characters, so I can at least understand the idea of 
> trusting the length field more than we trust the terminator.

Yea that's a fair point. Trusting the size makes sense given the embedded null 
case
 
> For libstdc++, I guess this happens because we have the simple summary 
> `${var._M_ptr}` (or whatever), but I think this actually shows that this 
> summary is wrong, as it will not print anything that comes after a (perfectly 
> legal) internal nul character

Yea in fact we have XFAILed tests for those

> Given that the terminator is a part of the std::string contract, I can also 
> imagine the formatter flagging this specially in some way (`"abc" 
> <unterminated>` ?)

That would be neat!


https://github.com/llvm/llvm-project/pull/147525
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to