pgsql: Fix compiler warnings on 64-bit Windows

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix compiler warnings on 64-bit Windows
Date: 2020-02-21 19:02:27
Message-ID: E1j5DZD-0003ah-IT@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix compiler warnings on 64-bit Windows

GCC reports various instances of

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

and MSVC equivalently

warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size
warning C4311: 'type cast': pointer truncation from 'void *' to 'long'

in ECPG test files. This is because void* and long are cast back and
forth, but on 64-bit Windows, these have different sizes. Fix by
using intptr_t instead.

The code actually worked fine because the integer values in use are
all small. So this is just to get the test code to compile warning-free.

This change is simplified by having made stdint.h required (commit
957338418b69e9774ccc1bab59f765a62f0aa6f9). Before this it would have
been more complicated because the ecpg test source files don't use the
full pg_config.h.

Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://www.postgresql.org/message-id/flat/5d398bbb-262a-5fed-d839-d0e5cff3c0d7%402ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3f9c1697dca0b4964f1f5ba624d361d4e0e53051

Modified Files
--------------
src/interfaces/ecpg/test/expected/thread-alloc.c | 41 ++++++-------
src/interfaces/ecpg/test/expected/thread-prep.c | 67 +++++++++++-----------
src/interfaces/ecpg/test/expected/thread-thread.c | 61 ++++++++++----------
.../ecpg/test/expected/thread-thread_implicit.c | 8 +--
src/interfaces/ecpg/test/thread/alloc.pgc | 7 ++-
src/interfaces/ecpg/test/thread/prep.pgc | 7 ++-
src/interfaces/ecpg/test/thread/thread.pgc | 7 ++-
.../ecpg/test/thread/thread_implicit.pgc | 8 +--
8 files changed, 106 insertions(+), 100 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-02-21 19:31:40 pgsql: Assume that we have rint().
Previous Message Jeff Davis 2020-02-21 17:48:27 pgsql: Fixup for nodeAgg.c refactor.