<div dir="ltr">It&#39;s also good to remember that IEEE floating-point was specifically designed such that doing an integer increment on the bitwise representation produces the next higher floating-point value. TBAA is for the birds and the optimizationists.</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Aug 8, 2025 at 2:59 PM Tiago Freire via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org">std-proposals@lists.isocpp.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
In my opinion, I as a programmer shouldn&#39;t have to deal with __floating_point types of any kind.</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
doubles and floats are annoying as it is and I&#39;m extremely happy that when <span style="color:rgb(0,0,0)">
&lt;stdfloat&gt; is implemented I don&#39;t have to touch them ever again.</span></div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
When I want a uint32_t I want an unsigned integer with 32 bits of precision because it fits the target problem I want to solve. I don&#39;t want to use an unsigned int and play the game of russian roulette depending on which compiler/target platform combination
 the code was compiled and end up with &quot;whatever&quot;...</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
You have 4 base completely distinct integer types, short, int, long, and long long. But they can only be one of 3 sizes 16, 32, or 64bit... yeah int8_t can not be made with one of those (it&#39;s a signed char, as in a character)...</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I want a 32bit IEEE 754 floating point and have it behave as such, not whatever a &quot;float&quot; just happens to be on a particular platform.</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I see no reason why these well-defined types shouldn&#39;t just be the standard types (no additional headers required), and if your platform has some other wishy-washy type then put that in a system specific library (that I don&#39;t want too ever look at or care that
 it exists).</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)" dir="auto">
But that&#39;s just me.</div>
<div dir="auto" id="m_-8554299949295400012mail-editor-reference-message-container">
<div dir="auto"><br>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_-8554299949295400012divRplyFwdMsg" style="font-size:11pt" dir="auto"><b>From:</b> Std-Proposals &lt;<a href="mailto:std-proposals-bounces@lists.isocpp.org" target="_blank">std-proposals-bounces@lists.isocpp.org</a>&gt; on behalf of Paul Caprioli via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt;<br>
<b>Sent:</b> Friday, August 8, 2025 8:21:18 PM<br>
<b>To:</b> <a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a> &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt;<br>
<b>Cc:</b> Paul Caprioli &lt;<a href="mailto:paul@hpkfft.com" target="_blank">paul@hpkfft.com</a>&gt;<br>
<b>Subject:</b> [std-proposals] TBAA and extended floating-point types<br>
</div>
<br>

<div dir="auto" style="font-size:11pt">Type-based aliasing analysis (TBAA) enables desirable optimizations, so it&#39;s generally undefined behavior to read or modify memory through a pointer to a different type.<br>
The standard specifies when the result of reinterpret_cast can be used to access memory.<br>
For example, for any object z of type std::complex&lt;T&gt;, reinterpret_cast&lt;T(&amp;)[2]&gt;(z)[0] is the real part of z.<br>
<br>
Supposing that double is IEEE-754 binary64 and ptr has type double*, is it safe to reinterpret_cast&lt;std​::​float64_t*&gt;(ptr) and then use it to read or modify memory that is an array of doubles?  I could not find that this is allowed, so I would like to float
 the idea for such a proposal.<br>
<br>
I&#39;m not sure whether the standard does/can/should say anything about implementation-specific types representing floating-point values.<br>
For example, on Apple hardware I might want to use intrinsics from arm_neon.h, which has typedef __fp16 float16_t; and provides vld1_f16(const float16_t *).<br>
Given const std::​float16_t* ptr, is it safe to use vld1_f16(reinterpret_cast&lt;const float16_t*&gt;(ptr)) ?<br>
<br>
Note that the __fp16 data type is not an arithmetic data type. The __fp16 data type is for storage and conversion only.  Arm recommends that for new code, you use the _Float16 data type instead of the __fp16 data type. __fp16 is an Arm C Language Extension.<br>
<br>
Also, the C++ standard has Recommended practice: Any names that the implementation provides for the extended floating-point types described in this subsection that are in addition to the names declared in the &lt;stdfloat&gt; header should be chosen to increase compatibility
 and interoperability with the interchange types _Float16, _Float32, _Float64, and _Float128 defined in ISO/IEC TS 18661-3 and with future versions of ISO/IEC 9899.<br>
<br>
I&#39;m wondering whether the standard does/can/should say anything about reinterpret_cast between _Float16* and __fp16* and using the resulting pointer to read or modify memory.<br>
<br>
Regards,<br>
Paul<br>
<br>
<br>
--<br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</div>
<br>
</div>
</div>

-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div>

