Top "Type-punning" questions

The process of reinterpreting an object of some data type as an object of some other data type.

What is the strict aliasing rule?

When asking about common undefined behavior in C, people sometimes refer to the strict aliasing rule. What are they talking …

c undefined-behavior strict-aliasing type-punning
Purpose of Unions in C and C++

I have used unions earlier comfortably; today I was alarmed when I read this post and came to know that …

c++ c unions type-punning
Fix for dereferencing type-punned pointer will break strict-aliasing

I'm trying to fix two warnings when compiling a specific program using GCC. The warnings are: warning: dereferencing type-punned pointer …

c strict-aliasing type-punning
Unions and type-punning

I've been searching for a while, but can't find a clear answer. Lots of people say that using unions to …

c++ c unions type-punning
Is type-punning through a union unspecified in C99, and has it become specified in C11?

A number of answers for the Stack Overflow question Getting the IEEE Single-precision bits for a float suggest using a …

c c99 unions c11 type-punning
What's a proper way of type-punning a float to an int and vice-versa?

The code below performs a fast inverse square root operation by some bit hacks. The algorithm was probably developed by …

c++ undefined-behavior gcc-warning strict-aliasing type-punning
Is it possible to write Quake's fast InvSqrt() function in Rust?

This is just to satisfy my own curiosity. Is there an implementation of this: float InvSqrt (float x) { float xhalf = 0.5…

rust floating-point sqrt type-punning