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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

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@v1` for the action)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to