alias question
Segher Boessenkool
segher@kernel.crashing.org
Sat Feb 19 09:41:00 GMT 2011
>> But not every type aliases character type!
>
> What? You can access any type with a char type,
> this is a specific exception.
Yes. And you cannot access a char as any type. The exception is
not symmetric in that way.
> Here's a concrete example.
> const short *w((short*)b);
That's not C code. I have no idea about the rules in C++..
> char b[4] = {0,0,0,0};
If it was C, then the objects b[...] have declared type "char", so
you are only allowed to access it as a character type; anything
else results in undefined behaviour.
Segher
More information about the Gcc-help
mailing list