Hi all,
I run IBM Rational Purify on this code:

CString aaa;
for (int i=0 ; i<100 ; i++) aaa+= "xxxxxxxxxxxxxxx\n";
aaa.Replace("\n","\r\n");

Purify issues this warnning message:
UMR: Uninitialized memory read in strstr {1 occurrence}
aaa.Replace("\n","\r\n");

Is this a known issue?
Is this a bug in CString/Purify?
How can I work around this?

Thanks very much!
Dudu Arbel

Re: CString bug? by David

David
Sun Apr 13 14:20:25 CDT 2008

>I run IBM Rational Purify on this code:
>
>CString aaa;
>for (int i=0 ; i<100 ; i++) aaa+= "xxxxxxxxxxxxxxx\n";
>aaa.Replace("\n","\r\n");
>
>Purify issues this warnning message:
>UMR: Uninitialized memory read in strstr {1 occurrence}
> aaa.Replace("\n","\r\n");
>
>Is this a known issue?
>Is this a bug in CString/Purify?
>How can I work around this?

Which version of VC++ are you using?

On the face of it, it would appear a bogus warning report.

Dave

Re: CString bug? by Tim

Tim
Sun Apr 13 17:39:22 CDT 2008

dududuil <dududuil@discussions.microsoft.com> wrote:
>
>Hi all,
>I run IBM Rational Purify on this code:
>
>CString aaa;
>for (int i=0 ; i<100 ; i++) aaa+= "xxxxxxxxxxxxxxx\n";
>aaa.Replace("\n","\r\n");
>
>Purify issues this warnning message:
>UMR: Uninitialized memory read in strstr {1 occurrence}
> aaa.Replace("\n","\r\n");
>
>Is this a known issue?
>Is this a bug in CString/Purify?
>How can I work around this?

It looks to me like overzealous reporting. You have the complete source
code for CString, so you can check it yourself. The only place where I can
possibly see this happening is in the StringTraits::CharNext call, when it
gets to the end of the buffer, but even in that case it won't matter.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: CString bug? by dududuil

dududuil
Mon Apr 14 04:47:00 CDT 2008

Tx for the reply,
I use VS6.0 (sp3).



"David Lowndes" wrote:

> >I run IBM Rational Purify on this code:
> >
> >CString aaa;
> >for (int i=0 ; i<100 ; i++) aaa+= "xxxxxxxxxxxxxxx\n";
> >aaa.Replace("\n","\r\n");
> >
> >Purify issues this warnning message:
> >UMR: Uninitialized memory read in strstr {1 occurrence}
> > aaa.Replace("\n","\r\n");
> >
> >Is this a known issue?
> >Is this a bug in CString/Purify?
> >How can I work around this?
>
> Which version of VC++ are you using?
>
> On the face of it, it would appear a bogus warning report.
>
> Dave
>

Re: CString bug? by David

David
Mon Apr 14 05:31:05 CDT 2008

>I use VS6.0 (sp3).

Try the last SP (6 I think) and see if there's any difference. Either
way, I'd probably ignore the warning unless there was real evidence of
a problem to be resolved.

Dave

Re: CString bug? by Tom

Tom
Tue Apr 15 00:24:43 CDT 2008

May not be the problem, but worth asking. Are you compiling as Unicode by
any chance? If so, perhaps you should try doing something like:

aaa += _T("xxxxxxxxxxxxxxxxxxxxxxx\n");

and

aaa.Replace(_T("\n",_T("\r\n"));

Also, do you mean to just do the replace on the last line added after the
for loop finishes?

Tom

"dududuil" <dududuil@discussions.microsoft.com> wrote in message
news:E7A4A6FA-A7ED-474F-970B-A6EDEBCCF701@microsoft.com...
> Hi all,
> I run IBM Rational Purify on this code:
>
> CString aaa;
> for (int i=0 ; i<100 ; i++) aaa+= "xxxxxxxxxxxxxxx\n";
> aaa.Replace("\n","\r\n");
>
> Purify issues this warnning message:
> UMR: Uninitialized memory read in strstr {1 occurrence}
> aaa.Replace("\n","\r\n");
>
> Is this a known issue?
> Is this a bug in CString/Purify?
> How can I work around this?
>
> Thanks very much!
> Dudu Arbel