Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: boundschecking

Author: Uri Blass

Date: 04:52:47 11/04/02

Go up one level in this thread


On November 04, 2002 at 07:22:56, Gerd Isenberg wrote:

>On November 04, 2002 at 04:59:03, Uri Blass wrote:
>
>>On November 04, 2002 at 04:32:20, Severi Salminen wrote:
>>
>>>>I can see randomize when I click F1 only as a visual basic command and I work in
>>>>C.
>>>>
>>>>I tried srand(0) before filling the array but it does not help and
>>>>zobrist[0][0][0] is different in debug mode and in release mode.
>>>
>>>Are you sure? I think rand() should return the exact same values if you use the
>>>same seed (srand()). Are you sure you run srand(0) and fill the table only once
>>>in both versions? There seems to be a bug somewhere.
>>>
>>>Severi
>>
>>I do not know maybe the problem is that I use rand64 for 64 bits numbers
>>
>>Here is the beginning of my code
>>
>>int main(void)
>>{
>>	char s[256];
>>	int i=0;
>>	char sizehash[9]="aaaaaaaaa";
>
>//  This char array needs size of 10 (char 9*'a' + '\0'-terminator)
>//  No error or warning ?
>//  MSC: error C2117: 'aaaaaaaaa' : array bounds overflow

I do not get an error or warning when I compile it so it seems to be a bug in
the compiler or maybe there is no '\0' terminator.

I store in sizehash[9] the number of mbytes in the hash table and more
information.
I read the number of mbytes to sizehash and later calculate the size of the hash
tables in the following way:

fgets(sizehash,9,hashfile);
while ((i<9)&&(sizehash[i]==' '))
 i++;

while ((i<9)&&(sizehash[i]>='0')&&(sizehash[i]<='9'))
	{

		hash_in_mbytes*=10;
		hash_in_mbytes=hash_in_mbytes+(int)sizehash[i]-(int)'0';
		i++;
	}


I have no good reason why did I defined sizehash[9]="aaaaaaaaa" and
I find that the program worked also without initializing sizehash.

I guess that at that time I thought that I may need 'a' to tell me the end of
the relevant information in the string but I do not need it.

Uri



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.