Re: UBSAN-safe way to convert from unsigned int to int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 20, 2025 at 03:45:19PM +0200, David Brown via Gcc-help wrote:
> If GCC wanted to add a way to re-interpret bits of a value of one type 
> as though it were another type, then perhaps __builtin_bit_cast could be 
> supported in C as well as C++.

+1.  I proposed this when it was done for C++, but no one (including
myself) implemented it.  No one was really opposed either iirc :-)

> I would expect that (and the C++ 
> function std::bit_cast<>) to do the conversion with optimal object code 
> and no run-time checking, regardless of any sanitiser flags.

Yeah, that is exactly what bit casts are :-)

> But that 
> would only help here if clang did the same.

LLVM can do whatever they want to do.  But they claim to be 100%
compatible to GCC, and in some things they actually are.


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux