Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Windows 64bit > VS2005 x64 VC++ codegen BUG

Reply
Thread Tools

VS2005 x64 VC++ codegen BUG

 
 
Sergey Kashyrin
Guest
Posts: n/a
 
      03-28-2006
Hi,

Here is the small program which is useless but can be compiled. Options are
(x64 version !!!) :

cl /c /Ox /Fatest /MD test.cpp

You can look at assembler code and see
mov rax, -7550501021876119059 ; 97373b532ad999edH
...
add rcx, rax
mov ebx, DWORD PTR [rsi+rcx*4+20]

It's incorrect "fhash" function inlining and implementation.


The first move looks like garbage and the last will fail (sigment violation)

The code is correct if optimizer is OFF (i.e. /Od) but in this case compiler
does not force "inline" for "fhash" function.

32-bit mode is ok with all options but it did not "inline" fhash function.

Regards,
Sergey

-------------------------- test.cpp -------------------------------------
#include <string.h>

const int NTBLHASH = 10007;

struct LTABL {
struct {
char c1[6];
char c2[6];
} location;
char key[16];
struct {
char num[3];
char id[13];
char rest[239];
} record;
char NONEXIST;
};

struct LTABLR {
int next;
LTABL tabl;
};

class TBLpool {
public:
int sz_mem;
int size;
int nfree;
int nused;

private:
int ifree;
int hash[NTBLHASH];
LTABLR rec[1];

int fhash(unsigned char * key) {
__int64 h = *key++;
for(int i = 0; i < 15; ++i) {
h <<= 2;
h ^= *key++;
}
int ret = (int)(h % NTBLHASH);
return ret;
}
public:
bool readTBL(LTABL * r) {
int x = hash[fhash((unsigned char *) r->key)];
while(x != 0) {
if(0 == memcmp(r, &rec[x].tabl, 16 + sizeof(r->location)))
{
*r = rec[x].tabl;
return true;
}
x = rec[x].next;
}
return false;
}
};

TBLpool * TBL;

bool TBLread(LTABL * r)
{
bool ret = TBL->readTBL(r);
return ret;
}


 
Reply With Quote
 
 
 
 
Andre Da Costa [Extended64]
Guest
Posts: n/a
 
      03-28-2006
Its best you post this to either or all of the following ngs:
microsoft.public.vc.language
microsoft.public.vc.alt
microsoft.public.vc.mfc
--
Andre
Extended64 | http://www.extended64.com
Blog | http://www.extended64.com/blogs/andre
http://spaces.msn.com/members/adacosta
FAQ for MS AntiSpy http://www.geocities.com/marfer_mvp/FAQ_MSantispy.htm

"Sergey Kashyrin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Here is the small program which is useless but can be compiled. Options
> are (x64 version !!!) :
>
> cl /c /Ox /Fatest /MD test.cpp
>
> You can look at assembler code and see
> mov rax, -7550501021876119059 ; 97373b532ad999edH
> ...
> add rcx, rax
> mov ebx, DWORD PTR [rsi+rcx*4+20]
>
> It's incorrect "fhash" function inlining and implementation.
>
>
> The first move looks like garbage and the last will fail (sigment
> violation)
>
> The code is correct if optimizer is OFF (i.e. /Od) but in this case
> compiler does not force "inline" for "fhash" function.
>
> 32-bit mode is ok with all options but it did not "inline" fhash function.
>
> Regards,
> Sergey
>
> -------------------------- test.cpp -------------------------------------
> #include <string.h>
>
> const int NTBLHASH = 10007;
>
> struct LTABL {
> struct {
> char c1[6];
> char c2[6];
> } location;
> char key[16];
> struct {
> char num[3];
> char id[13];
> char rest[239];
> } record;
> char NONEXIST;
> };
>
> struct LTABLR {
> int next;
> LTABL tabl;
> };
>
> class TBLpool {
> public:
> int sz_mem;
> int size;
> int nfree;
> int nused;
>
> private:
> int ifree;
> int hash[NTBLHASH];
> LTABLR rec[1];
>
> int fhash(unsigned char * key) {
> __int64 h = *key++;
> for(int i = 0; i < 15; ++i) {
> h <<= 2;
> h ^= *key++;
> }
> int ret = (int)(h % NTBLHASH);
> return ret;
> }
> public:
> bool readTBL(LTABL * r) {
> int x = hash[fhash((unsigned char *) r->key)];
> while(x != 0) {
> if(0 == memcmp(r, &rec[x].tabl, 16 + sizeof(r->location)))
> {
> *r = rec[x].tabl;
> return true;
> }
> x = rec[x].next;
> }
> return false;
> }
> };
>
> TBLpool * TBL;
>
> bool TBLread(LTABL * r)
> {
> bool ret = TBL->readTBL(r);
> return ret;
> }
>
>



 
Reply With Quote
 
 
 
 
Sergey Kashyrin
Guest
Posts: n/a
 
      03-29-2006
Thanks, Andre.

I've crossposted it to vc.language but I thought it's ok to post here
because it's strict x64 issue.
The intention is just to make MS guys aware of this bug, because it's not
critical and I just don't want to go with "pay-per-incindent" support.

And in this case the question is what this group for ?

Regards,
Sergey


"Andre Da Costa [Extended64]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Its best you post this to either or all of the following ngs:
> microsoft.public.vc.language
> microsoft.public.vc.alt
> microsoft.public.vc.mfc
> --
> Andre
> Extended64 | http://www.extended64.com
> Blog | http://www.extended64.com/blogs/andre
> http://spaces.msn.com/members/adacosta
> FAQ for MS AntiSpy http://www.geocities.com/marfer_mvp/FAQ_MSantispy.htm
>
> "Sergey Kashyrin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi,
>>
>> Here is the small program which is useless but can be compiled. Options
>> are (x64 version !!!) :
>>
>> cl /c /Ox /Fatest /MD test.cpp
>>
>> You can look at assembler code and see
>> mov rax, -7550501021876119059 ; 97373b532ad999edH
>> ...
>> add rcx, rax
>> mov ebx, DWORD PTR [rsi+rcx*4+20]
>>
>> It's incorrect "fhash" function inlining and implementation.
>>
>>
>> The first move looks like garbage and the last will fail (sigment
>> violation)
>>
>> The code is correct if optimizer is OFF (i.e. /Od) but in this case
>> compiler does not force "inline" for "fhash" function.
>>
>> 32-bit mode is ok with all options but it did not "inline" fhash
>> function.
>>
>> Regards,
>> Sergey
>>
>> -------------------------- test.cpp -------------------------------------
>> #include <string.h>
>>
>> const int NTBLHASH = 10007;
>>
>> struct LTABL {
>> struct {
>> char c1[6];
>> char c2[6];
>> } location;
>> char key[16];
>> struct {
>> char num[3];
>> char id[13];
>> char rest[239];
>> } record;
>> char NONEXIST;
>> };
>>
>> struct LTABLR {
>> int next;
>> LTABL tabl;
>> };
>>
>> class TBLpool {
>> public:
>> int sz_mem;
>> int size;
>> int nfree;
>> int nused;
>>
>> private:
>> int ifree;
>> int hash[NTBLHASH];
>> LTABLR rec[1];
>>
>> int fhash(unsigned char * key) {
>> __int64 h = *key++;
>> for(int i = 0; i < 15; ++i) {
>> h <<= 2;
>> h ^= *key++;
>> }
>> int ret = (int)(h % NTBLHASH);
>> return ret;
>> }
>> public:
>> bool readTBL(LTABL * r) {
>> int x = hash[fhash((unsigned char *) r->key)];
>> while(x != 0) {
>> if(0 == memcmp(r, &rec[x].tabl, 16 + sizeof(r->location)))
>> {
>> *r = rec[x].tabl;
>> return true;
>> }
>> x = rec[x].next;
>> }
>> return false;
>> }
>> };
>>
>> TBLpool * TBL;
>>
>> bool TBLread(LTABL * r)
>> {
>> bool ret = TBL->readTBL(r);
>> return ret;
>> }
>>
>>

>
>



 
Reply With Quote
 
Andre Da Costa [Extended64]
Guest
Posts: n/a
 
      03-29-2006
Well, its not really a programming group, but some knowledgeable persons in
the developer languages do drop by here from time to time, so its not a
problem. I just wanted to direct you to a better answer quicker.
--
--
Andre
Windows Connected | http://www.windowsconnected.com
Extended64 | http://www.extended64.com
Blog | http://www.extended64.com/blogs/andre
http://spaces.msn.com/members/adacosta

"Sergey Kashyrin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks, Andre.
>
> I've crossposted it to vc.language but I thought it's ok to post here
> because it's strict x64 issue.
> The intention is just to make MS guys aware of this bug, because it's not
> critical and I just don't want to go with "pay-per-incindent" support.
>
> And in this case the question is what this group for ?
>
> Regards,
> Sergey
>
>
> "Andre Da Costa [Extended64]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Its best you post this to either or all of the following ngs:
>> microsoft.public.vc.language
>> microsoft.public.vc.alt
>> microsoft.public.vc.mfc
>> --
>> Andre
>> Extended64 | http://www.extended64.com
>> Blog | http://www.extended64.com/blogs/andre
>> http://spaces.msn.com/members/adacosta
>> FAQ for MS AntiSpy http://www.geocities.com/marfer_mvp/FAQ_MSantispy.htm
>>
>> "Sergey Kashyrin" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Hi,
>>>
>>> Here is the small program which is useless but can be compiled. Options
>>> are (x64 version !!!) :
>>>
>>> cl /c /Ox /Fatest /MD test.cpp
>>>
>>> You can look at assembler code and see
>>> mov rax, -7550501021876119059 ; 97373b532ad999edH
>>> ...
>>> add rcx, rax
>>> mov ebx, DWORD PTR [rsi+rcx*4+20]
>>>
>>> It's incorrect "fhash" function inlining and implementation.
>>>
>>>
>>> The first move looks like garbage and the last will fail (sigment
>>> violation)
>>>
>>> The code is correct if optimizer is OFF (i.e. /Od) but in this case
>>> compiler does not force "inline" for "fhash" function.
>>>
>>> 32-bit mode is ok with all options but it did not "inline" fhash
>>> function.
>>>
>>> Regards,
>>> Sergey
>>>
>>> --------------------------
>>> test.cpp -------------------------------------
>>> #include <string.h>
>>>
>>> const int NTBLHASH = 10007;
>>>
>>> struct LTABL {
>>> struct {
>>> char c1[6];
>>> char c2[6];
>>> } location;
>>> char key[16];
>>> struct {
>>> char num[3];
>>> char id[13];
>>> char rest[239];
>>> } record;
>>> char NONEXIST;
>>> };
>>>
>>> struct LTABLR {
>>> int next;
>>> LTABL tabl;
>>> };
>>>
>>> class TBLpool {
>>> public:
>>> int sz_mem;
>>> int size;
>>> int nfree;
>>> int nused;
>>>
>>> private:
>>> int ifree;
>>> int hash[NTBLHASH];
>>> LTABLR rec[1];
>>>
>>> int fhash(unsigned char * key) {
>>> __int64 h = *key++;
>>> for(int i = 0; i < 15; ++i) {
>>> h <<= 2;
>>> h ^= *key++;
>>> }
>>> int ret = (int)(h % NTBLHASH);
>>> return ret;
>>> }
>>> public:
>>> bool readTBL(LTABL * r) {
>>> int x = hash[fhash((unsigned char *) r->key)];
>>> while(x != 0) {
>>> if(0 == memcmp(r, &rec[x].tabl, 16 + sizeof(r->location)))
>>> {
>>> *r = rec[x].tabl;
>>> return true;
>>> }
>>> x = rec[x].next;
>>> }
>>> return false;
>>> }
>>> };
>>>
>>> TBLpool * TBL;
>>>
>>> bool TBLread(LTABL * r)
>>> {
>>> bool ret = TBL->readTBL(r);
>>> return ret;
>>> }
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Jochen Kalmbach [MVP]
Guest
Posts: n/a
 
      03-29-2006
Hi Sergey!

> It's incorrect "fhash" function inlining and implementation.


You should report bugs here:
http://lab.msdn.microsoft.com/ProductFeedback/

And then post the link to this bug, so we can validate and vote for it...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
VS2005 - DefaultValuesNeeded - bug? Adding default values in DataGridView dbuchanan ASP .Net 7 05-23-2006 05:09 PM
Codegen Group Briza-97 Mid Tower ATX Case Silverstrand Front Page News 0 09-27-2005 01:46 PM
codegen:nullValue, Using Annotations with a Typed DataSet, Not resolved never! Efy. ASP .Net 1 09-22-2003 02:50 PM
Missing CODEGEN values from DataSet Web Reference and Properties are not updated Ken Beard ASP .Net Web Services 4 07-28-2003 06:15 AM



Advertisments