Fix compiler warnings on 64-bit Windows

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix compiler warnings on 64-bit Windows
Date: 2020-02-13 14:16:57
Message-ID: 5d398bbb-262a-5fed-d839-d0e5cff3c0d7@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Fix-compiler-warnings-on-64-bit-Windows.patch text/plain 10.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabrízio de Royes Mello 2020-02-13 14:27:50 Re: Bug in pg_restore with EventTrigger in parallel mode
Previous Message Julien Rouhaud 2020-02-13 13:40:32 Re: allow running parts of src/tools/msvc/ under not Windows