Quantcast
Channel: User CPlus - Programming Language Design and Implementation Stack Exchange
Viewing all articles
Browse latest Browse all 66

Why is type reinterpretation considered highly problematic in many programming languages?

$
0
0

C++ disallows reinterpret_cast from int to float as far as I know, and using a union or pointer cast to reinterpret an int to a float or vice versa or even an int to a short[2] is undefined behavior. In C using a union is valid but using a pointer cast remains invalid. Most languages have no facilities to reinterpret the bits of one type to another.

Why are languages often averse to reinterpret/bitcasting a type to an 'unrelated' type. What are the advantages or disadvantages of allowing this?


Viewing all articles
Browse latest Browse all 66

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>