On 29 June 2006 16:15, Kaveh R. Ghazi wrote:
> > On Jun 29, 2006, at 9:51 AM, Dave Korn wrote:
> >
> > That's cheating! You casted away const, it's a blatant aliasing
> > violation, you deserve everything you get.
> >
> > No it is not, in fact it is legal C and there is no aliasing violation
> > as you are still accessing the memory as an "int".
> > -- Pinski
>
> "Legal" does not mean it's a good idea. Bypassing const through casts
> is like ignoring documentation. You get what you deserve.
>
> E.g. if the object referred to by the pointer is in a read-only
> section, casting away const-ness and modifying it leads to a core
> dump...
>
> --Kaveh
I believe that's basically what Andreas was pointing out; in that case, you
*are* violating the type of the underlying object.
cheers,
DaveK
--
Can't think of a witty .sigline today....