[cfe-dev] Possible bug in CLang 3.7.1 / 3.8.0

Aleksander Alekseev via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 25 03:26:34 PDT 2016


Hello

Here is a test program:

```
#include <string.h>

int main()
{
  (void)strlcpy;
  return 0;
}
```

When I compile it using clang 3.6 compiler reports an error:

```
$ /usr/bin/clang-3.6 str.c -o str
str.c:5:9: error: use of undeclared identifier 'strlcpy'; did you mean
'struct'?

str.c:5:9: error: expected expression
2 errors generated.
```

Its OK, this is an expected behavior.

But newer versions of CLang somehow manage to build this program:

```
$ /usr/local/bin/clang-3.7 str.c -o str

str.c:5:9: warning: implicitly declaring library function 'strlcpy'
with type 'unsigned long (char *, const char *, unsigned
long)'

str.c:5:9: note: include the header <string.h> or explicitly provide a
declaration for 'strlcpy'

1 warning generated.

$ ./str 

$ /usr/local/bin/clang-3.8 str.c -o str

str.c:5:9: warning: implicitly declaring library function 'strlcpy'
with type 'unsigned long (char *, const char *, unsigned
long)' [-Wimplicit-function-declaration]

str.c:5:9: note: include the header <string.h> or explicitly provide a
declaration for 'strlcpy' 1 warning generated.
```

First of all <string.h> is already included. Also there is no strlcpy
procedure on this system at all (Ubuntu Linux 14.04 x64). Thus this
program should not compile.

It seems to be a serious bug since projects that use Autotools rely on
clang 3.6 behaviour while checking weather current system has strlcpy
procedure.

Or maybe I just don't understand something?

-- 
Best regards,
Aleksander Alekseev
http://eax.me/



More information about the cfe-dev mailing list