[PATCH] D107654: [Flang] Fix error messages on Windows.

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 10 13:48:57 PDT 2021


amccarth added a comment.

Thanks for making the change more local.



================
Comment at: flang/lib/Parser/message.cpp:44
+  // used in some messages.
+  int need{_vsprintf_p(nullptr, 0, p, ap)};
+#else
----------------
I understand the intent is to determine the size of the buffer needed, but the [Microsoft documentation for `_vsprintf_p`][1] says,

> If the buffer or format parameters are NULL pointers, ... the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, the functions return -1 and set errno to EINVAL.

But since this is passing a null pointer for the buffer, I'd expect this to abort or return -1.  Maybe that's a documentation bug.  Has this been tested on Windows?

[1]: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l?view=msvc-160#remarks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107654



More information about the llvm-commits mailing list