Win64 warnings about size_t

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Win64 warnings about size_t
Date: 2010-01-01 17:32:08
Message-ID: 9837222c1001010932j523921a7j5abebc46e4456210@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have adapted the win64 patches a bit, and now have a working build.
As in it runs the regression tests fine. However, I have well over a
thousand warnings of the type:
conversion from 'size_t' to 'int', possible loss of data

My first 5-6 checks of where these happen are all cases where we
assign the result of strlen() something to an int, or call a function
taking an int as parameter with the result of strlen() in there.

strlen() returns size_t, which AFAICS is per the standard and not even
a Microsoft-specific idea. size_t is 8-bit - but it appears to be
8-bit on Linux as well, when in 64-bit mode.

So I don't really see what win64 does differently in this case, but
perhaps I've been looking at this code too long? Or is it simply that
MSVC warns about this and GCC doesn't, and I shuld disbale the
warning?

A couple of points for reference:

1>.\src\backend\utils\adt\varlena.c(84) : warning C4267: 'function' :
conversion from 'size_t' to 'int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(158) : warning C4267: 'function' :
conversion from 'size_t' to 'int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(158) : warning C4267: 'function' :
conversion from 'size_t' to 'int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(201) : warning C4267: '=' :
conversion from 'size_t' to 'int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(203) : warning C4267: 'function' :
conversion from 'size_t' to 'unsigned int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(488) : warning C4267: 'function' :
conversion from 'size_t' to 'int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(2156) : warning C4267: 'function'
: conversion from 'size_t' to 'int', possible loss of data
1>.\src\backend\utils\adt\varlena.c(3131) : warning C4267: '=' :
conversion from 'size_t' to 'int32', possible loss of data
1>.\src\backend\utils\adt\varlena.c(3136) : warning C4267: '=' :
conversion from 'size_t' to 'int32', possible loss of data

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-01-01 17:35:49 Re: Cancelling idle in transaction state
Previous Message Robert Haas 2010-01-01 17:24:50 Re: Cancelling idle in transaction state