Re: basic_string causes crash in _vsnprintf???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Some good ideas, we were thinking along the same lines, just wish there was a
reliable way to detect this situation in the code, otherwise I have little
choice but to build an implementation that works or suffer through rigorous
testing to make sure all code paths have been taken so we have eliminated any
potential crashes due to this issue, and even then unless we use macros like
you suggest it is easy for someone to just stick in new code that could fail
since there are no warnings.



"muchan" wrote:

> WXS wrote:
> > Still probably 6-10,000+ unknown lines of any varags method taking strings
> > too many to verify 100% correct in a day or two.
> >
>
>
> For a day or two, you switch back to the CString, and migrating the copy of
> the code to std::string taking more time. ;)
>
> I sometimes forget to put .c_str(), and have tried build a mechanism
> to catch the error in compile time. My basic idea was to make a template
> functions with the same name, with std:string in the 1st, 2nd, 3rd, 4th,
> parameter. If the argument matched, the function is resolved to that
> dummy function to issue the compile error.
>
> For a day or two, ;) I tried, but failed. The dificulty was automatic
> casting from char * or LPCSTR to std::string. Ambiguity was the problem.
> Because I'm old ex-C programer, I'm much familiar with "%d %s %lf" things
> than modern ostreambuffer things, still prefer using sprintf like functions.
>
> (My current thinking is that C++ and vararg aren't good pair.
> Just reluctant to move _now_ to stream formatting...)
>
> Using a utility function std::string format(char *fmt, ...), as
> a wrapper for sprintf(), I still want to integrate the auto-parameter-checking
> for detecting the missing .c_str(). You may try yours, maybe at first
> defining a function to catch single std::string argument for "%s", and
> wrappes it to redirect with c_str().
> It may reduce your 10,000+ to 5,000+ or so... :)
>
>
> muchan
>
>
>
>
>
>
>
.



Relevant Pages

  • Re: basic_string causes crash in _vsnprintf???
    ... to catch the error in compile time. ... dummy function to issue the compile error. ... Because I'm old ex-C programer, I'm much familiar with "%d %s %lf" things than modern ostreambuffer things, still prefer using sprintf like functions. ... a wrapper for sprintf, I still want to integrate the auto-parameter-checking for detecting the missing .c_str. ...
    (microsoft.public.vc.stl)
  • Re: cffi: calls with variable number of arguments determined at runtime
    ... ;; but what if i do not know the types and arguments at compile time? ... ;; these are stupid examples and none of them work, ...
    (comp.lang.lisp)
  • Re: cffi: calls with variable number of arguments determined at runtime
    ... ;; but what if i do not know the types and arguments at compile time? ... ;; these are stupid examples and none of them work, ...
    (comp.lang.lisp)
  • Re: Using constants
    ... > I wish to use constants in place of numbers when dimensioning string ... > arrays. ... code at compile time ... going to cause a compile error ...
    (comp.lang.cpp)
  • Re: Can I do Subclassing in Class module?
    ... I called OldWindowProc = SetWindowLong(myForm.hWnd, GWL_WNDPROC, ... AddressOf NewWindowProc) but error occurs at compile time like ... "Compile error: ...
    (comp.lang.basic.visual.misc)