Rudy Ray Moore wrote:
void f(unsigned int) {}
void f(unsigned long) {}
int main()
{
size_t t = 0;
f(t);
return 0;
}
//----------------------------
With 64 bit warnings enabled, why does this code warn C4267? This warning
is particularly annoying because it warns whever I do a "Stream <<
container.size()"
warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int',
possible loss of data
In Win64, size_t widens to 64 bits, while int and long remain 32 bits.
Evidently, the 32-bit compiler thinks size_t is unsigned int in Win64 (as it
is in Win32), so it overlooks the ambiguity you would encounter compiling
the above with the 64-bit compiler and gives you a spurious warning.
--
Doug Harrison
Microsoft MVP - Visual C++