Re: const correctness

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Cc: "Peter Eisentraut" <peter_e@gmx.net>, "Peter Geoghegan" <peter@2ndquadrant.com>, "Thomas Munro" <munro@ip9.org>, pgsql-hackers@postgresql.org
Date: 2011-11-10T20:10:31Z
Lists: pgsql-hackers
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom mentioned the strchr() function, which does do that.  I don't
> actually find that surprising given my understanding of the
> semantics.  That means that the function is promising not to modify
> the character array, but is not asserting that it knows the
> character array to be immutable.  Makes sense to me.  It's up to the
> caller to assign it to a "const char *" if it knows it passed in an
> immutable object.
 
The problem with it of course is that mistaken use could have the
effect of casting-away-const, which is exactly what we hoped to prevent.
Still, there may not be a better solution.

			regards, tom lane