[libcxx-commits] [PATCH] D59727: [libc++] Fix return value of snprintf_l() on Windows when buffer is too small

Tom Anderson via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 22 17:10:17 PDT 2019


thomasanderson added a comment.

In D59727#1440354 <https://reviews.llvm.org/D59727#1440354>, @EricWF wrote:

> I'm never comfortable using other STL's implementation details. When a user does that to libc++, we slap their hand.
>  And MSVC docs explicitly ask us not to use that here:
>  https://docs.microsoft.com/en-us/cpp/c-runtime-library/internal-crt-globals-and-functions?view=vs-2017
>
> Is there any other paths forward?


There's a messy solution that doesn't rely on internals.  We could use `_vsnprintf_s_l()` and if the return value is -1 and errno is ERANGE, then we know the buffer is too small.  Then we would have to fall back on the old slow codepath to get the buffer size.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59727/new/

https://reviews.llvm.org/D59727





More information about the libcxx-commits mailing list