[LLVMdev] [Patch] WinCOFFObjectWriter: fix for storing pointer to string table in header name field

Richard legalize at xmission.com
Tue Jul 23 11:51:03 PDT 2013


In article <CACs=tyLqAn7GNNobgwr+K96k-Zw1y5N16dzOeOB2O8OtrHyNig at mail.gmail.com>,
    Reid Kleckner <rnk at google.com> writes:

> Nuh uh: "The _snprintf function formats and stores count or fewer
> characters in buffer, and appends a terminating null character if the
> formatted string length is strictly less than count characters."
> http://msdn.microsoft.com/en-us/library/2ts7cx93(v=vs.100).aspx
> 
> Please don't assume snprintf always null terminates.
> 
> This may be Windows-specific behavior that you shouldn't rely on.  If
> that's the case, ignore my suggestion.

Yes, _snprintf with MSVC is not a conforming C99 (or whatever) standard
implementation of snprintf.  I've filed a bug on it, but don't expect
a fix from them anytime soon as they deem it low priority.

This is just another reason to stay away from these error-prone C APIs
in C++ code.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>



More information about the llvm-dev mailing list