Skip site navigation (1) Skip section navigation (2)

Re: msvc const warnings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "Magnus Hagander" <magnus(at)hagander(dot)net>, "pgsql-patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: msvc const warnings
Date: 2007-07-24 15:03:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Magnus Hagander" <magnus(at)hagander(dot)net> writes:
>> Stefan mentioned that the warning may be one that shows up in a different
>> compiler somewhere as well, thouh, which might indicate that we should fix
>> the underlying issue? (Even if the code is correct, if it confuses multiple
>> compilers...)

> I think the right fix is just to remove the const qualifier. It's clearly not
> treating the pointer as const if it's passing it to pfree which is surely a
> state change if anything is.

That was what you claimed in the previous discussion, but you were wrong
then and you're still wrong.  The pointer is "const char **" which means
it is a pointer to some pointers that are not themselves constant.  That
is, the palloc'd area *contains* pointers to const strings, but that
doesn't make the palloc'd area itself const.  You're making the same
mistake msvc does.

I agree though that the #pragma solution is awfully ugly.  What I'd
be inclined to do is

	/* cast away indirect const to avoid warnings from broken compilers */
	free((void *) headers);

			regards, tom lane

In response to


pgsql-patches by date

Next:From: Gregory StarkDate: 2007-07-24 15:24:35
Subject: Re: msvc const warnings
Previous:From: Andrew DunstanDate: 2007-07-24 14:57:12
Subject: Re: plperl warnings on win32

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group