C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] [isocpp-ext] Report from the recent C/C++ liaison meeting (SG22); includes new floating point types(!)

From: Matthias Kretz <m.kretz_at_[hidden]>
Date: Mon, 20 Sep 2021 10:49:55 +0200
On Saturday, 18 September 2021 22:36:40 CEST David Olsen wrote:
> When float and _Float32 have the same representation and sets of values, can
> well-formed C code detect the difference between "float + _Float32 ->
> _Float32" and "float + _Float32 -> float" without using a _Generic
> expression? Are there situations where the result type of "float +
> _Float32" affects the correctness of the program or the behavior of a
> correct program? It would be very easy to detect this in C++. I can't
> think of how to detect the difference in C without resorting to _Generic,
> though I don't know C as well.
>
> If the user writes code that is valid in both C and C++ (assuming that the
> user has dealt with the fact that _Float32 and std::float32_t are different
> names for essentially the same type in the two languages), will the fact
> that "float + _Float32/std::float32_t" have different result types in the
> two languages cause any differences in behavior?

One could theorize over an implementation that, when compiling with fast-math,
implements std::float32_t and _Float32 to unconditionally conform to IEC 60559
*semantics* (i.e. ignore fast-math flags). Then it makes the difference of IEC
conforming behavior vs. fast-math behavior.

-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 stdₓ::simd
──────────────────────────────────────────────────────────────────────────

Received on 2021-09-20 03:50:08