[flang-commits] [flang] 5b14bd0 - Reland "[flang] Fix a warning"

David Spickett via flang-commits flang-commits at lists.llvm.org
Fri Jan 12 07:30:44 PST 2024


Author: David Spickett
Date: 2024-01-12T15:29:50Z
New Revision: 5b14bd01f500be33ad94f14dca6f5cb33c623ee7

URL: https://github.com/llvm/llvm-project/commit/5b14bd01f500be33ad94f14dca6f5cb33c623ee7
DIFF: https://github.com/llvm/llvm-project/commit/5b14bd01f500be33ad94f14dca6f5cb33c623ee7.diff

LOG: Reland "[flang] Fix a warning"

This reverts commit 4210eb1d704c3ba602328efc8924147b2e98ed18.

I didn't realise this was going to break every -Werror bot,
so I guess we'll take the test suite failure until a fix is found,
it's less disruptive.

Added: 
    

Modified: 
    flang/runtime/extensions.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/extensions.cpp b/flang/runtime/extensions.cpp
index f72acf83a4409f..352da8f11d9d56 100644
--- a/flang/runtime/extensions.cpp
+++ b/flang/runtime/extensions.cpp
@@ -108,12 +108,13 @@ void FORTRAN_PROCEDURE_NAME(getlog)(std::byte *arg, std::int64_t length) {
   if (nameMaxLen == -1)
     nameMaxLen = _POSIX_LOGIN_NAME_MAX + 1;
 #endif
-  char str[nameMaxLen];
+  std::vector<char> str(nameMaxLen);
 
-  int error{getlogin_r(str, nameMaxLen)};
+  int error{getlogin_r(str.data(), nameMaxLen)};
   if (error == 0) {
     // no error: find first \0 in string then pad from there
-    CopyAndPad(reinterpret_cast<char *>(arg), str, length, std::strlen(str));
+    CopyAndPad(reinterpret_cast<char *>(arg), str.data(), length,
+        std::strlen(str.data()));
   } else {
     // error occur: get username from environment variable
     GetUsernameEnvVar("LOGNAME", arg, length);


        


More information about the flang-commits mailing list