RE: basic_string causes crash in _vsnprintf???



I wanted to thank everyone for the thoughts and ideas on this topic.
I was able to get our code running to some extent by fixing the strings to
call c_str() in only a few places but I'm sure I am leaving time bombs in the
code at this point so we'll probably run in the current mode for nowand
consider a replacement class or test the heck out of the thing to do make
sure we have hit all of the major code paths.

I was wondering if anyone knows if a PCLint like product will detect this
issue we could use on our code base?

Thanks,
Dave


"WXS" wrote:

> The code below used to work fine with stlport and VC++ 6.0. I migrated the
> project to VS2003 C++ and now I get an exception within _vsnprintf when it
> tries to get the tstring variable test from the variable arguments list
> within the output function in the CRT internals it instead gets the value
> 0xcdcdcdcd instead of the pointer to the string.
>
> Anyone know why?
>
>
> //
> // typedef a TCHAR string as a tstring for future internationalization
> //
> typedef basic_string<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > tstring;
>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
>
>
> tstring test="MyTest";
> enum {MyItem1,MyItem2};
>
> CString info2="MyTest";
> TRACE2("%s(%d)", info2, MyItem1); //Works
> TRACE2("%s(%d)", test, MyItem1); //Causes exception
> return 0;
> }
.



Relevant Pages

  • Re: Secure C programming & format strings
    ... I hope fixing the problem doesn't involve doing ... >:the above operation on all your printfs. ... I know for certain that string literals are constant by default, ... unless they are used in an array initialization (char* s1="abc" is ...
    (comp.security.misc)
  • Re: instance_eval, yield, C extensions
    ... Daniel Berger wrote: ... fixing that I get "can't convert Proc into String ". ...
    (comp.lang.ruby)
  • Re: Reg Exp
    ... I was at work and we were fixing to leave so I was rushed to ... the only string I want to get from that input is stringn. ... character but it doesn't matter how many there are with \w+, ...
    (comp.lang.java.programmer)