Skip to content

Commit 5b14bd0

Browse files
committed
Reland "[flang] Fix a warning"
This reverts commit 4210eb1. 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.
1 parent 9fdc568 commit 5b14bd0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

flang/runtime/extensions.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ void FORTRAN_PROCEDURE_NAME(getlog)(std::byte *arg, std::int64_t length) {
108108
if (nameMaxLen == -1)
109109
nameMaxLen = _POSIX_LOGIN_NAME_MAX + 1;
110110
#endif
111-
char str[nameMaxLen];
111+
std::vector<char> str(nameMaxLen);
112112

113-
int error{getlogin_r(str, nameMaxLen)};
113+
int error{getlogin_r(str.data(), nameMaxLen)};
114114
if (error == 0) {
115115
// no error: find first \0 in string then pad from there
116-
CopyAndPad(reinterpret_cast<char *>(arg), str, length, std::strlen(str));
116+
CopyAndPad(reinterpret_cast<char *>(arg), str.data(), length,
117+
std::strlen(str.data()));
117118
} else {
118119
// error occur: get username from environment variable
119120
GetUsernameEnvVar("LOGNAME", arg, length);

0 commit comments

Comments
 (0)