Re: const correctness
Kevin Grittner <kevin.grittner@wicourts.gov>
From: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
To: "Tom Lane" <tgl@sss.pgh.pa.us>
Cc: "Robert Haas" <robertmhaas@gmail.com>, "Thomas Munro" <munro@ip9.org>,<pgsql-hackers@postgresql.org>
Date: 2011-11-09T23:49:08Z
Lists: pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote: > In general I don't have an objection to adding "const" to > individual routines, so long as it doesn't create propagating > requirements to const-ify other code. This may be the only way to > do it. As I understand it (although I'm no C expert), a "const" qualifier on a function parameter declaration is a promise that the function will not modify what is thus qualified. That means that it can't pass a const parameter to another function as a parameter not also declared const. It doesn't say anything about the object itself or what is returned from the function. So a non-const parameter in can be passed to a const parameter in a call, but not vice versa. And a variable need not be declared const to pass it to a function as a const parameter. I don't know if this meets your conditions for non-propagation. -Kevin