Re: A malloc error in C++
Re: A malloc error in C++
- Subject: Re: A malloc error in C++
- From: Jack Repenning <email@hidden>
- Date: Wed, 29 Aug 2007 08:41:36 -0700
On Aug 29, 2007, at 8:28 AM, Giacomo Monari wrote:
Btw it is really weird... As everybody noted that main is
structured in blocks so I tried to gradually comment those blocks
to see where the error lays...
Well the answer is in this part:
{
GMNLFS::DataAnalysis<vector<double>::iterator,double> llsAnalysis
(lls.begin(),lls.end());
cout << "Max lls = " << llsAnalysis.GetMax() << endl;
cout << "Min lls = " << llsAnalysis.GetMin() << endl;
cout << "Average lls = " << llsAnalysis.GetAverage() << endl;
cout << "Variance of lls = " << llsAnalysis.GetVariance() << endl;
cout << "Standard Deviation of lls = " <<
llsAnalysis.GetStdDeviation() << endl;
cout << "Skewness of lls = " << llsAnalysis.GetSkewness() << endl;
cout << "Kurtosis of lls = " << llsAnalysis.GetKurtosis() << endl;
cout << " ------------------------------------- " << endl;
//llsAnalysis.~DataAnalysis();
}
wich doesn't seem that different to the other blocks...
Once you start corrupting your data (and calling the destructor
directly is a fast track to data corruption), the effects can be
wildly unpredictable. They hardly ever make any real sense unless
you analyze the individual instruction sequences, which is just what
you're trying NOT to do by using a high-level language. The problem
is, you're violating the very patterns the language system is trying
to use to free you from machine-level debugging. All bets are off.
You created the object llsAnalysis and the others in your other
blocks "on the stack" (inside some {}'s, and without calling new).
That means its the compiler's job to call ~DataAnalysis. Trust it;
you'll be fine.
-==-
Jack Repenning
Chief Technology Officer
CollabNet, Inc.
8000 Marina Boulevard, Suite 600
Brisbane, California 94005
office: +1 650.228.2562
mobile: +1 408.835.8090
raindance: +1 877.326.2337, x844.7461
aim: jackrepenning
skype: jrepenning
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden