[cfe-dev] Bug with sentinel attribute in clang

Andreas Enge andreas.enge at inria.fr
Wed Apr 6 08:29:00 PDT 2011


The attached code, compiled with
   clang -Wall varfunc.c
creates the warning
varfunc.c:27:30: warning: missing sentinel in function call
   printf ("%d\n", add_em_up (3, 5, 5, 6, (int *) 0));
                             ^
varfunc.c:8:1: note: function has been explicitly marked sentinel here                         
add_em_up (int count,...)

Replacing "(int *) 0" by "(void *) 0" or "NULL" solves the problem. However,
the gcc documentation at
   http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
stipulates that
   A valid NULL in this context is defined as zero with any pointer type. If your system defines the NULL macro with an integer type then you need to add an explicit cast. GCC replaces stddef.h with a copy that redefines NULL appropriately. 

Indeed, gcc compiles the attached code without problem. So this looks like
a bug in clang.

Output of "clang --version":
clang version 1.1 (Debian 2.7-3)
Target: i386-pc-linux-gnu
Thread model: posix

Andreas

PS: I would have filed a bug, were it not for the need of creating an account.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: varfunc.c
Type: text/x-csrc
Size: 528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110406/77a6cd6a/attachment.c>


More information about the cfe-dev mailing list