473,385 Members | 1,806 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,385 software developers and data experts.

VC 64-bit compiler BUG

Probably there is bug in VC 64-bit compiler (in all versions)

Compile and run the following code with speed optimization (-O2):

#include <stdio.h>

typedef int (*fp)(const unsigned char *buf, unsigned int pos, unsigned int
num);

int f(const unsigned char *buf, unsigned int pos, unsigned int num)
{
int sum = 0;
for (; num != 0; num--)
sum += buf[(size_t)pos++];
return sum;
}

fp t = f;

int main()
{
unsigned char buffer[1] = { 0 };
unsigned int pos = 0x80000000;
return t(buffer - pos, pos, 1);
}

Bug description:
pos is unsigned int, but VC compiler uses
movsxd r9, edx
command to extend from unsigned int to size_t

Feb 1 '07 #1
1 1408
Igor Pavlov wrote:
Probably there is bug in VC 64-bit compiler (in all versions)

Compile and run the following code with speed optimization (-O2):

#include <stdio.h>

typedef int (*fp)(const unsigned char *buf, unsigned int pos,
unsigned int num);

int f(const unsigned char *buf, unsigned int pos, unsigned int num)
{
int sum = 0;
for (; num != 0; num--)
sum += buf[(size_t)pos++];
return sum;
}

fp t = f;

int main()
{
unsigned char buffer[1] = { 0 };
unsigned int pos = 0x80000000;
return t(buffer - pos, pos, 1);
}

Bug description:
pos is unsigned int, but VC compiler uses
movsxd r9, edx
command to extend from unsigned int to size_t
That does sound like a bug, although it's impossible to tell from a single
assembly instruction without having a 64-bit compiler to try it out on.

Please post a bug report at

http://connect.microsoft.com/feedback?SiteID=210

-cd
Feb 1 '07 #2

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

Similar topics

1
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, XP boots from C and XP 64 boots from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32) which...
56
by: Dave Vandervies | last post by:
I just fixed a bug that some of the correctness pedants around here may find useful as ammunition. The problem was that some code would, very occasionally, die with a segmentation violation...
0
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, Win XP boots from C and Win XP 64 boot from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32)...
10
by: krunalb | last post by:
Hi, I am trying to shift unsigned long long value by 64 bits and this is what i get #include <stdio.h> int main() { unsigned short shiftby= 64;
1
by: =?Utf-8?B?UGF1bCBQaGlsbGlwcw==?= | last post by:
I have read many things about this but I haven't got a clear vision on what to do if anything about this. I have a system that tries to find holes in my web site. One of the things it has...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.