Subject: Re: [std-proposals] Avoid copies when using string_view with APIs expecting null terminated strings
From: Nikolay Mihaylov (nmmm_at_[hidden])
Date: 2020-12-27 02:34:55
... the point is...
stealing bits from pointer is not portable, even between compilers. I know
it can be done for x64 and probably Arm 64, but for Arm32 or 32 bit Intel -
I am not sure.
On Sunday, December 27, 2020, Thiago Macieira via Std-Proposals <
> On Saturday, 26 December 2020 19:06:25 -03 Arthur O'Dwyer wrote:
> > Storing in the pointer: almost certainly not okay, unless I have failed
> > keep up with C++20 constexpr rules. string_view is specified to be
> > constexpr-friendly in C++17 and later. That means no type-punning.
> std::string_view is a Standard Library class. Implementations are free to
> extensions that colour pointers in a constexpr fashion. In fact, they
> want to do that so that the compiler itself can keep track of what it did,
> for extensions like ASan. And the good thing about colour pointers is that
> don't have to remove the extra bits to dereference the data, so there's no
> casting required.
> One of the problems with colour pointers is that there's no convention
> on who gets to use which pointers. ASan would definitely like to use some
> those bits, but it can't use the ones that the library uses...
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DPG Cloud Engineering
> Std-Proposals mailing list
STD-PROPOSALS list run by email@example.com
Standard Proposals Archives on Google Groups