Windows 64 bit warnings

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Windows 64 bit warnings
Date: 2011-04-17 00:46:44
Message-ID: 4DAA3874.2090903@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


While looking into setting up some libraries to use for 64 bit Windows
builds, I took a quick look at the output from the 64 bit postgres
builds currently running. They're actually quite clean, a heck of a lot
cleaner than several other packages I have been looking at, quite a good
testament to the cleanliness of our code. I was looking specifically for
instances of warnings like "warning: cast to pointer from integer of
different size" or the other way around, and found just two.

One is at src/interfaces/ecpg/ecpglib/sqlda.c:231, which is this line:

sqlda->sqlvar[i].sqlformat = (char *) (long) PQfformat(res, i);

I'm not clear about the purpose of this anyway. It doesn't seem to be
used anywhere, and the comment on the field says it for future use. If
we're going to do it, I think it should be cast to a long long on Win64,
since a char * is 8 bytes there, while a long is only 4. But if we
really want to store the result from PQfformat() in it, why is it a char
* at all?

The other, slightly more serious case, is at
src/test/regress/pg_regress.c:2280, which is this code:

printf(_("running on port %d with pid %lu\n"),
port, (unsigned long) postmaster_pid);

Here the postmaster_pid is in fact a HANDLE which is 8 bytes, and so it
should probably be cast to an unsigned long long and rendered with the
format %llu in Win64.

cheers

andrew

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Browne 2011-04-17 01:12:25 Re: Formatting Curmudgeons WAS: MMAP Buffers
Previous Message Tom Lane 2011-04-16 23:55:04 WIP patch for allowing COLLATE in plpgsql variable declarations