bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] inttostr.h: add compile-time buffer overrun checks


From: Paul Eggert
Subject: Re: [PATCH] inttostr.h: add compile-time buffer overrun checks
Date: Mon, 18 Oct 2010 10:29:29 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8

On 10/18/10 04:53, Pádraig Brady wrote:

> /* Like sizeof, except that it treats a variable sized array
>    as a pointer rather than determining the size at runtime.  */
> #define CT_SIZEOF(x) (__builtin_constant_p(sizeof x) ? sizeof x: sizeof 
> (void*))

I don't see how this would work.  If x is a variable-sized
array, CT_SIZEOF(x) is not a constant expression, according
to the C rules, because for A?B:C to be a constant expression,
B and C both have to be constant expressions.

Besides, there's really not that much need to be worried about
older GCC compilers.  They are being upgraded all the time, and
the problem will go away.  In the meantime, we're going to be
catching the errors anyway, since we'll be using the newer compilers.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]