Click to See Complete Forum and Search --> : Assert error in VC 6 but not in VC 5


Jim Bassett
June 3rd, 1999, 03:36 PM
Programming Problems:

I am having a problem with some code that works fine in Visual Studio 5.0 but throws an ASSERT fail in Visual Studio 6.0. The code is as follows:

Timeslice is a CString = "58988", therefore it has a length of five. An assert fail is thrown on the third line below which should just return an empty string, just like the fourth and fifth line. That is it does in 5.0 without any problems, but an assert fail is being thrown in Visual Studio 6.0.


Day = Timeslice.Left(3);
Hour = Timeslice.Mid(4,2);
Minute = Timeslice.Mid(7,2);
Second = Timeslice.Mid(10,2);
MilliSecond = Timeslice.Mid(13,4);

Has anyone seen other occurrence like this?
Could anyone test this out and report to me for a sanity check on my part.

Thanks for you help,
Pam Cable
pcable@csc.com

cdehaven
June 3rd, 1999, 04:16 PM
Hi Pam,

Yeh, I tried it under 6.0 and yes, it does assert. But if you look at the assertion, it's because they're checking the total length of the string against the parameters you're passing in.



ASSERT (nFirst + nCount <= GetData()->nDataLength)





In you case, nFirst is 7 and your nCount gets nailed to a zero inside Mid(). Why the assert in 6.0 and not 5.0? An enhancement?

Curt