This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why are we not using const?


 > 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
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]