Re: [GD-General] The joy of type aliasing and C
Brought to you by:
vexxed72
|
From: Alen L. <ale...@cr...> - 2004-01-03 08:57:20
|
>int x = ( int & ) f; >int x = * ( int * ) &f; >In the above, both the 'f' are considered lvalues, since they are >expressions with an object type. I thought so. :/ >> The reinterpret_cast operator is _designed_ to be used for type >> punning, isn't it? >Typically only for modifying pointer types, e.g. derived pointer to >base class, etc. But it does compile without errors when used to do type punning (FWIK). Weirdo. Is there some statement in the standard, ignored by compilers, that says it shouldn't? I'm not reading the standard, but some Deep C++ articles, saying: "While the Standard gives static_cast a sweeping general property plus a complicated set of exceptions, it limits reinterpret_cast to two fundamental roles: - Conversions to and from pointers - Overlaying an lvalue with multiple types (a.k.a. type punning) " So maybe that creates some confusion. Is the statement above correct? Alen |