On 11/26/2015 8:51 AM, Andrey Semashev wrote:
On 2015-11-26 05:13, Agustín K-ballo Bergé wrote:
On 11/25/2015 10:52 PM, Andrey Semashev wrote:
IMHO, the standard should just follow C11 semantics and say it more clearly.
That's unlikely to happen, C has *vastly* weaker aliasing rules than C++, to the point that several C implementations choose to follow the C++ rules instead. You'd be asking for the opposite to happen.
I can see the benefits of strict aliasing rules in other contexts, but unions specifically exist to provide the common storage for objects of different types in a relatively less messy way compared to, e.g. a raw byte buffer. I'm not seeing people using unions and somehow expecting type aliasing to not happen, quite the contrary. I think the language here is being too limiting for no practical reason.
How would that work? If one could read a `float` as if it were an `int`, then ints and floats may alias. If they may alias, then whenever you get a pointer to an `int` you'll have to ask could it be this other `float` instead? Until the whole program is compiled and all `union`s are seen, everything may alias with anything else. We'd be back in a land of bits and bytes... Regards, -- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com