[llvm-bugs] [Bug 50786] New: Clang recommends `string.h` for missing `strndup` declaration
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jun 21 05:55:25 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50786
Bug ID: 50786
Summary: Clang recommends `string.h` for missing `strndup`
declaration
Product: clang
Version: 12.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C
Assignee: unassignedclangbugs at nondot.org
Reporter: prs.ttg+llvm at pm.me
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Clang recommends `string.h` for missing `strndup` declaration despite `strndup`
not being part of `string.h` under the Windows libc.
This means that compilation of something like this:
```
#include <string.h>
char* test(const char* str, size_t n) {
return strndup(str, n);
}
...
```
would result in:
```
implicitly declaring library function 'strndup' with type 'char *(const char *,
unsigned long long)' [-Wimplicit-function-declaration]
return strndup(str, n);
^
note: include the header <string.h> or explicitly provide a declaration for
'strndup'
```
which is quite misleading.
I'm not sure if there is a way to see whether a given header provides a decl
under a given compilation env, or if it would just be a case of not treating
`strndup` as a library function on windows targets.
This came to light from GH Actions CI so I can't really provide many more
details on the environment - clang seems to be installed from
'https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/LLVM-12.0.0-win64.exe'
(using `egor-tensin/setup-clang at v1` for the action)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210621/6cd0a31a/attachment.html>
More information about the llvm-bugs
mailing list