Re: Questions about warnings

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Questions about warnings
Date: 2007-01-25 13:18:57
Message-ID: 20070125131857.GD27011@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 25, 2007 at 01:38:14PM +0100, Peter Eisentraut wrote:
> Magnus Hagander wrote:
> > I'm looking over the VC build trying to eliminate what warnings are
> > left. One thing that appears in a couple of places is stuff like:
> >
> > .\src\bin\psql\print.c(2014): warning C4090: 'function' : different
> > 'const' qualifiers
> >
> > This happens in psql when we do free() on a variable that's "const
> > char **". The same thing happens in oracle_compat.c in the backend
> > with pfree().
>
> The code in question is:
>
> const char **headers;
>
> [...]
>
> free(headers);

Right, and similar code for pfree().

> > Is this a warning we should care about and remove (or change?) the
> > const qualifyer? Or should I just ignore it?
>
> My free() takes a pointer to void, which should be able to point to any
> type of data, and certainly pointer to pointer to const char fits that
> description. So I think the compiler is overly zealous.
>
> Actually writing into the supposedly constant data pointed to by
> a "const type *" pointer would be a potential bug, but GCC catches
> that, so we can be reasonably assured that this is OK in the current
> code.

I won't claim to know the inners good enough to comment on it. Does
"const char **" really mean that the point is const, or the pointer that
it points to is const?

Anyway, I'll just ignore the warnings then. I'll leave them enabled
in the compiler since they might catch other similar things that are
actually bugs in the future, and it's only 6 warnings in psql and 2 in
oracle_compat in total..

//Magnus

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-01-25 13:20:10 Re: Questions about warnings
Previous Message Gregory Stark 2007-01-25 13:11:15 Re: Questions about warnings