Date: Sat, 18 Sep 2021 13:26:20 -0700 (PDT)
On Sat, 18 Sep 2021 20:36:40 +0000 David Olsen via Liaison wrote:
>
>Matthias Kretz pointed out that the proposed rules for C and C++ have different arithmetic conversion rules:
>>> float + _Float32 -> _Float32
>>> float + std::float32 -> float.
>
>As Jens said, "Not good." It's also unfortunate that I didn't notice this difference sooner. But before I start to panic about this, I want to understand what the impact of this difference is.
>
>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?
>
How about places where 'float' promotes to 'double' and '_Float32' does not promote?
Such as printf()?
>
>Matthias Kretz pointed out that the proposed rules for C and C++ have different arithmetic conversion rules:
>>> float + _Float32 -> _Float32
>>> float + std::float32 -> float.
>
>As Jens said, "Not good." It's also unfortunate that I didn't notice this difference sooner. But before I start to panic about this, I want to understand what the impact of this difference is.
>
>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?
>
How about places where 'float' promotes to 'double' and '_Float32' does not promote?
Such as printf()?
--- Fred J. Tydeman Tydeman Consulting tydeman_at_[hidden] Testing, numerics, programming +1 (702) 608-6093 Vice-chair of PL22.11 (ANSI "C") Sample C99+FPCE tests: http://www.tybor.com Savers sleep well, investors eat well, spenders work forever.
Received on 2021-09-18 16:26:26