Now to my problem. After instantiation of the object tempArray it's member variables array_ and size_ are invalid. size_ in this case should be 9 as array.size_ = 10. If I use GDB to analyse tempArray.size_ from within the Differentiate() member function it's showing a value of 4253902!

Now, the strange thing is, I know my constructor for Array<double> is working correctly because if I step into the creation of tempArray the member variables are setup correctly, but upon return from the constructor the member variables are no longer the same.

Has anybody seen behaviour like this? I'm suspecting a stack corruption maybe. I have been running with libDUMA though so it should hopefully rule that out.

Ok, I think this might a non-issue or a tools problem or more likely a problem with the person using them, aka me!

The actual code runs and works ok. I have a loop in the Differentiate() function that reads in the size of tempArray and it loops 9 times. Except that GDB tells me the value of that variable is 4253902.

I have seen this behaviour before when using optimisation, but that's turned off by using the -O0 switch. I must be using it wrong so if anyone knows why GDB is doing this let me know!

The reason I know it's working is the the for loop in the above function is executing 9 times which is correct. If the value being used was as read from GDB it would be cycling 4253902 times and probably seg fault on an array index out of bounds. Also I have a test harness which exercises the functions with known patterns and results and these are all correct.

I'm not an expert with this, but I have one idea / suggestion. This value of 4254684 looks a lot like a pointer value (converted to integer). Is it possible that you have a binary compatibility problem? Did you make sure that the static library in which the Array class template is instantiated into Array<double> is actually compiled with all the exact same compiler options? Maybe you can try to output via a member function (which is not as sensitive to binary compatibility problems) the value in integer form of the pointer array_. Just use a printf like you did for size() but for the pointer and compare that to the value that GDB outputs for the data member size_. I am suggesting that because it would explain why the function size() outputs the right value while GDB finds the wrong one. If binary compatibility is the issue, that behavior makes sense (GDB assumes a different binary footprint for the class and thus, looks at the wrong place for the value of size_, possibly where the pointer array_ is located in memory).

After some searching around and googling it looks like GDB does not handle C++ well in some cases and is made worse with templates. I think I'll raise a bug against GDB and see what the community suggest.

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...