THIRD EDIT: Feel free to delete this problem. Turns out the object hadn't been allocated... so when I'd access it's vars they weren't allocated either. Arg.
I've been building a transposition table in C++ so it came up that I needed 64 bit random numbers (don't ask..) so I built this function:
Code:
long long int Ttable::randomLong()
{
int firstHalf, secondHalf;
long long int newRand;
firstHalf = rand();
secondHalf = rand();
//copy the first value into the top 32 bits
newRand = firstHalf;
newRand = newRand << 32;
//XOR in the second half covering up all the new zero bits
newRand = newRand ^ secondHalf;
return newRand;
}
And all of the variables I assign to it such as:
Code:
white = randomLong();
or for testing
Code:
cerr << randomLong();
give me segfaults when I go to use em. I know I'm probably missing something simple. If you can't find anything and know of a good *default* 64 bit random number generator that'd also.. probably be fine.
While I wait I'll go recheck the code with a standard random function... but that should work fine.
I haven't gotten any useful info from GDB or valgrind other than helping me find that these vars are the ones segfaulting.
Thanks
-E
EDIT:
I changed to rand() and it still hasn't worked. I must be doing something incorrect at declaration?
Code:
long long int white;
I'm going to back up the files and try out the "standard" 64 bit int, should be int64_t. I hadn't thought that that could be a problem :S. Will report back if change is successful.
SECOND EDIT:
Didn't change anything. I still don't see what it's doing that would cause an allocation problem. These aren't pointers :S.