Skip to content

Commit

Permalink
Revert "[flang] Fix a warning"
Browse files Browse the repository at this point in the history
This reverts commit 18734f6.

This caused a test suite failure on our bots:
https://lab.llvm.org/buildbot/#/builders/184/builds/9407

```
$ ~/stage1.install/bin/flang-new flush_1.f90
/usr/bin/ld: /home/david.spickett/stage1.install/lib/libFortranRuntime.a(extensions.cpp.o): in function `getlog_':
extensions.cpp:(.text.getlog_+0x1c): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: extensions.cpp:(.text.getlog_+0x7c): undefined reference to `operator delete(void*)'
/usr/bin/ld: extensions.cpp:(.text.getlog_+0xc4): undefined reference to `operator delete(void*)'
/usr/bin/ld: extensions.cpp:(.text.getlog_+0xe8): undefined reference to `operator delete(void*)'
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
```
  • Loading branch information
DavidSpickett committed Jan 12, 2024
1 parent 4f47372 commit 4210eb1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions flang/runtime/extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ void FORTRAN_PROCEDURE_NAME(getlog)(std::byte *arg, std::int64_t length) {
if (nameMaxLen == -1)
nameMaxLen = _POSIX_LOGIN_NAME_MAX + 1;
#endif
std::vector<char> str(nameMaxLen);
char str[nameMaxLen];

int error{getlogin_r(str.data(), nameMaxLen)};
int error{getlogin_r(str, nameMaxLen)};
if (error == 0) {
// no error: find first \0 in string then pad from there
CopyAndPad(reinterpret_cast<char *>(arg), str.data(), length,
std::strlen(str.data()));
CopyAndPad(reinterpret_cast<char *>(arg), str, length, std::strlen(str));
} else {
// error occur: get username from environment variable
GetUsernameEnvVar("LOGNAME", arg, length);
Expand Down

0 comments on commit 4210eb1

Please sign in to comment.