Re: ilist.h fails cpluspluscheck - Mailing list pgsql-hackers

From Andres Freund
Subject Re: ilist.h fails cpluspluscheck
Date
Msg-id 20121127095651.GA3989@awork2.anarazel.de
Whole thread Raw
In response to Re: ilist.h fails cpluspluscheck  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ilist.h fails cpluspluscheck
List pgsql-hackers
On 2012-11-27 01:14:27 -0500, Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > In file included from ./src/include/utils/catcache.h:25:0,
> >                  from /tmp/cpluspluscheck.bt8VZr/test.cpp:3:
> > src/include/lib/ilist.h: In function ‘dlist_node* dlist_head_node(dlist_head*)’:
> > src/include/lib/ilist.h:470:39: error: invalid conversion from ‘void*’ to ‘dlist_node*’ [-fpermissive]
>
> > Maybe some ifndef __cplusplus would help.
>
> Or maybe we need to recommend use of -fpermissive?  If C++ thinks
> casting void * to something else is illegitimate, it's basically not
> going to cope with most things we might try to inline in Postgres.
> And I don't think that saying "you don't get to call these fundamental
> support functions from C++" is likely to fly, so just hiding the
> functions won't help much.

Its rather easy to fix in the ilist code at least - the cases it points
out are those where I took a slightly ugly shortcut to reduce some very
minor code duplication...

Some casts fix it, alternatively the

     Assert(!dlist_is_empty());
     return head->head.next
could be moved into [ds]list_(head|tail)_node instead of relying on the
*_elemen_off support functions.

Greetings,

Andres

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Piyush Newe
Date:
Subject: Re: gset updated patch
Next
From: Jeff Davis
Date:
Subject: Re: MySQL search query is not executing in Postgres DB