[cfe-dev] Bug with sentinel attribute in clang

Eli Friedman eli.friedman at gmail.com
Wed Apr 6 11:25:58 PDT 2011


On Wed, Apr 6, 2011 at 8:29 AM, Andreas Enge <andreas.enge at inria.fr> wrote:
> 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

The version of clang you're using is relatively ancient; your testcase
works fine on trunk.

-Eli




More information about the cfe-dev mailing list