Re: implicit casts from void*

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: implicit casts from void*
Date: 2025-07-01 03:36:10
Message-ID: 3073834.1751340970@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

John Naylor <johncnaylorls(at)gmail(dot)com> writes:
> I received on off-list report that commit e2809e3a101 causes an error
> when building an extension written in C++, since $subject is in a
> header file. The fix is simply to add an explicit cast, so I plan to
> push the attached soon.

Hmpfh. No objection to your patch, but I wonder why
"headerscheck --cplusplus" didn't find this? Can we get it
to do so?

> Bikeshedding: We could additionally change the pg_crc*.c files to make
> them consistent, but I have not done that yet. It seems we prefer
> explicit casts anyway but don't enforce that.

Meh. There are an awful lot of places where we assume such casts
are okay. I'm willing to adopt a stricter definition in header
files, but it feels like requiring it in .c files is useless
make-work. As a perhaps not quite exact parallel, we mostly
don't object to writing

if (ptr)

as a shortcut for

if (ptr != NULL)

though it's hard to see the former as anything but an implicit
cast to boolean.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-07-01 03:50:09 Correct comment atop PublicationPartOpt
Previous Message Tom Lane 2025-07-01 03:21:15 Re: Tags in the commitfest app: How to use them and what tags to add?