Bug#651454: confused about strlcat and strlcpy

Peter Eisentraut petere at debian.org
Thu Dec 8 19:18:08 UTC 2011


Package: clang
Version: 3.0-2
Severity: normal

Apparently, clang 3.0 has a feature that it implicitly assumes the
declaration of well-known C library functions.  For example, this is
broken:

$ cat test.c
int
main ()
{
    (void) foobar;
    return 0;
}
$ $ clang -c test.c
test.c:4:12: error: use of undeclared identifier 'foobar'
    (void) foobar;
           ^
1 error generated.

But this is now magic:

$ cat test.c
int
main ()
{
    (void) strcat;
    return 0;
}
$ clang -c test.c
test.c:4:12: warning: implicitly declaring C library function 'strcat' with type 'char *(char *, const char *)'
    (void) strcat;
           ^
test.c:4:12: note: please include the header <string.h> or explicitly provide a declaration for 'strcat'
1 warning generated.

The problem is now when you do this with strlcat or strlcpy.  clang
will report a note just like above with strcat, but the C library on
Debian (GNU/Linux) does not contain strlcat or strlcpy, so this
behavior is wrong.

The reason this is a real problem is that the Autoconf macro
AC_CHECK_DECLS uses code like I showed to determine whether a function
is declared.  So calling

AC_CHECK_DECLS([strlcat, strlcpy])

will go by fine, but when you compile the actual program later, it will
produce lots of warnings.

I would argue that the whole feature of implicitly declaring C library
functions is stupid, but at least applying it to strlcat and strlcpy
is wrong on Debian (GNU/Linux).  I'm reporting it here first because I
don't know whether it's an upstream or an integration problem.  One
would think that the clang build process actually checks what
functions the C library provides.

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (101, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 3.0.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages clang depends on:
ii  libc6               2.13-21  
ii  libffi5             3.0.10-3 
ii  libgcc1             1:4.6.2-5
ii  libllvm3.0          3.0-3    
ii  libstdc++6          4.6.2-5  
ii  libstdc++6-4.6-dev  4.6.2-5  

Versions of packages clang recommends:
ii  llvm-3.0-dev  3.0-3  
ii  python        2.7.2-9

clang suggests no packages.

-- no debconf information





More information about the Pkg-llvm-team mailing list