Re: const correctness

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "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 19:57:48
Message-ID: 4EBBD85C0200002500042CEE@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On ons, 2011-11-09 at 10:49 -0500, Tom Lane wrote:
>> Now admittedly you can hack it, in the same
>> spirit as the C library functions that are declared to take const
>> pointers and return non-const pointers to the very same data
>
> Which C library functions do that?

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.

-Kevin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-11-10 19:59:20 Re: foreign key locks, 2nd attempt
Previous Message Peter Eisentraut 2011-11-10 19:57:43 Re: -Wcast-qual cleanup, part 1