473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Inappropriate warning


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

Thanks,

Rudy
Nov 17 '05 #1
1 994
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++
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex Shi | last post by:
Hello, I got an error message when trying following script: <? //...... if (!$handle = fsockopen ("ssl://my.com", 443, $errno, $errstr, $timeout = 30)) { print "$errno: $errstr\n"; return...
3
by: Bill Burris | last post by:
How do I find what is causing this warning from the Linker? If I use /NODEFAULTLIB I get hundreds of undefined symbols. LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other...
1
by: spanov | last post by:
i've got problem installing python-2.3.5 from sources on FreeBSD 5.3 root@server# ./configure > conf_log configure: WARNING: curses.h: present but cannot be compiled configure: WARNING:...
8
by: stefano | last post by:
HI, I have aproblem with XHTML radio button. <form name=" form"> <input name="radio" type="radio" onclick="return false" /> <input name="radio" type="radio" onclick="return false" /> <input...
14
by: Ben | last post by:
I have recently learned how list comprehension works and am finding it extremely cool. I am worried, however, that I may be stuffing it into places that it does not belong. What's the most...
0
by: Laszlo Nagy | last post by:
Hi All, I have a python program that downloads database backups from a remote server, and tries to replace the local database with the downloaded backup. The database is a PostgreSQL server and my...
12
by: tshad | last post by:
Does anyone have or know where I can get a some code that will check a TextBox for inappropriate language. At the moment, we need to manually check submissions for language before posting. This...
4
by: cody | last post by:
It is possible to declare and use/instantiate a class with a uninitialized readonly field without even a compiler warning. Why don't I get warnings? public class Stuff { public readonly int a;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.