Re: [PATCH] quiet conversion warning in DatumGetFloat4

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] quiet conversion warning in DatumGetFloat4
Date: 2017-05-31 15:36:18
Message-ID: 22297.1496244978@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chapman Flack <chap(at)anastigmatix(dot)net> writes:
> On 05/31/17 01:26, Tom Lane wrote:
>> Hm. I think it would be better to use DatumGetInt32 here. Arguably,
>> direct use of GET_4_BYTES and its siblings should only appear in
>> DatumGetFoo macros.

> Like so? These are the 4 sites where {GET,SET}_n_BYTES got introduced
> in 14cca1b (for consistency, though only the GET_4 case produces warnings).

After experimenting with -Wconversion, I see why we don't use it in
server builds --- it produces an astonishing number of mostly-useless
warnings, which apparently can only be silenced by introducing explicit
casts. I do not think that cluttering our code with lots more explicit
casts would be a win for either readability or safety.

However, I grant your point that some extensions may have outside
constraints that mandate using -Wconversion, so to the extent that
we can keep key headers like postgres.h from triggering those warnings,
it's probably worth doing. I suspect you're still seeing a lot of them
though --- experiments with some contrib modules suggest that a lot of
our other headers also contain code that would trigger them. I do not
think I'd be on board with trying to silence them generally.

However, the present patch seems harmless enough, and arguably a tad
cleaner than what we had, so pushed.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2017-05-31 15:36:50 ALTER INDEX .. SET STATISTICS ... behaviour
Previous Message Mark Dilger 2017-05-31 15:28:51 Re: Use of non-restart-safe storage by temp_tablespaces