Hi.
I'm having trouble debugging a rather large project. The first issuse is not knowing how to track the bug down.

Here is the text from Assertion Error popup while running in debug mode
Debug Assertion Failed

Program...nga Path\file.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\xtoa.c
Line: 105

Expression: sizeInTChars > (size_t)(is_neg ? 2: 1)

I'm unsure as to how I can find which part of code is causing the problem.

Here is the particular piece of code which the above ifo breaks at.

        TCHAR *p;                /* pointer to traverse string */
        TCHAR *firstdig;         /* pointer to first digit */
        TCHAR temp;              /* temp char */
        unsigned digval;         /* value of digit */
#ifdef _SECURE_ITOA
        size_t length;           /* current length of the string */

        /* validation section */
        _VALIDATE_RETURN_ERRCODE(buf != NULL, EINVAL);
        _VALIDATE_RETURN_ERRCODE(sizeInTChars > 0, EINVAL);
        _RESET_STRING(buf, sizeInTChars);
        _VALIDATE_RETURN_ERRCODE(sizeInTChars > (size_t)(is_neg ? 2 : 1), ERANGE); // <<<
        _VALIDATE_RETURN_ERRCODE(2 <= radix && radix <= 36, EINVAL);
        length = 0;

#endif  /* _SECURE_ITOA */

I'm not awfully clever with debugging yet and just don't know where to start, I tried searching my project for a reference to "itoa()" function but can not find one.

Can anyone help?

Somewhere in your code you are calling a function with some bad values, and that function probably calls another, and another, and so on, until finally the function that has to deal with those bad values discovers they're bad.

If you build with debugging symbols on, the error should present you with a stack trace (i.e. a list of all the functions that have been called as described above) and one of them is yours. That's the code you need to fix.

Not quite sure where sizeInTChars comes from but it would appear that it's value is 0 when is should be at least 1 or 2. This looks like parameter checking of a function so I'm guessing sizeInTChars might be a function parameter in which case somewhere you have called the function (xtoa?) with invalid parameters.

Thank you kindly for suggestions.
Looking at call stack helped me track down problem, I had searched for whole word "itoa" and in code using "_itoa_s" and it was there, where it seems the bug was.

Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.