All Questions
Tagged with c23 type-punning
2
questions
10
votes
2
answers
280
views
Does nullptr_t break type punning or pointer conversions?
Consider this union:
typedef union
{
void* vptr;
nullptr_t nptr;
} pun_intended;
nullptr_t is supposedly compatible with void* 1). Ok so what if we initialize the void* to some non-zero ...
2
votes
1
answer
350
views
Implementing std::bit_cast equivalent in C
Is it possible to implement something similar to C++20's std::bit_cast in C? It would be a lot more convenient than using union or casting pointers to different types and dereferencing.
If you had a ...