On Wed, 21 Jun 2023, Richard Biener via Gcc-patches wrote: > > > int32_t x = (int32_t)0x1.0p32; > > > int32_t y = (int32_t)(int64_t)0x1.0p32; > > > > > > sets x to 2147483647 and y to 0. > > Hmm, good question. GENERIC has a direct truncation to unsigned char > for example, the C standard generally says if the integral part cannot > be represented then the behavior is undefined. So I think we should be > safe here (0x1.0p32 doesn't fit an int).
We should be following Annex F (unspecified value plus "invalid" exception for out-of-range floating-to-integer conversions rather than undefined behavior). But we don't achieve that very well at present (see bug 93806 comments 27-29 for examples of how such conversions produce wobbly values). -- Joseph S. Myers jos...@codesourcery.com