Re: const correctness

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Peter Geoghegan" <peter(at)2ndquadrant(dot)com>, "Thomas Munro" <munro(at)ip9(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: const correctness
Date: 2011-11-10 20:10:31
Message-ID: 13350.1320955831@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2011-11-10 20:13:52 Re: pl/python custom datatype parsers
Previous Message Tom Lane 2011-11-10 20:08:12 Re: pg_dump 9.1.1 hanging (collectSecLabels gets 0 labels)