C++ Logo

std-proposals

Advanced search

Re: [std-proposals] TBAA and extended floating-point types

From: Paul Caprioli <paul_at_[hidden]>
Date: Tue, 26 Aug 2025 20:43:26 +0000
> In my opinion, unless the non-aliasing type restrictions are removed, Yes, the "unless" idea was my original thought that I emailed to this list. The types double and std::float64_t are different; one is not a typedef of the other. But, we could say the two types may alias analogously to the way double and std::complex<double> may alias. Then, as Tiago F suggests, reinterpret_cast should work. > the following is required: > > An operation very much like std::start_lifetime_as() is needed in place of reinterpret_cast. > Another operation, perhaps the same operation with types reversed, must be written at the point where the programmer wants changes to be synchronized. > In between those two operations, the memory must only be accessed via std::float64_t. > Before and after both operations, the memory must only be accessed via double. A difficulty is that std::start_lifetime_as_array() returns a pointer. I don't think one may use the old pointer to refer to objects of the new lifetime type. Or, maybe you can if you launder it? The member function std::vector::data() returns a pointer, not a reference to the pointer. So, how do we jam the result of a proposed std::cast_unchecked<double*>(std::float64_t*) into the vector? Or, do we propose std::vector::launder()? This is becoming unteachable.

Received on 2025-08-26 20:43:29