Re: Questions about warnings

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Questions about warnings
Дата
Msg-id 200701251338.15280.peter_e@gmx.net
обсуждение исходный текст
Ответ на Questions about warnings  (Magnus Hagander <magnus@hagander.net>)
Ответы Re: Questions about warnings  (Gregory Stark <stark@enterprisedb.com>)
Re: Questions about warnings  (Magnus Hagander <magnus@hagander.net>)
Список pgsql-hackers
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);

> 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.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: ECPG buglet?
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: Questions about warnings