[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] inttostr.h: add compile-time buffer overrun checks
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] inttostr.h: add compile-time buffer overrun checks |
Date: |
Tue, 19 Oct 2010 00:17:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
On 18/10/10 18:29, Paul Eggert wrote:
> 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.
I did verify it, but on gcc 4.1.3.
I've just now checked that gcc 3.0 does also constant fold the above,
while gcc 2.95 does not.
> 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.
I understand that. My main reasoning was to have
the simpler solution as a stepping stone to understanding
the more complicated one.
cheers,
Pádraig.
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, (continued)
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Jim Meyering, 2010/10/17
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Bruno Haible, 2010/10/17
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Jim Meyering, 2010/10/17
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Bruno Haible, 2010/10/17
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Pádraig Brady, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Paolo Bonzini, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Bruno Haible, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Paul Eggert, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Ben Pfaff, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Pádraig Brady, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks,
Pádraig Brady <=
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Jim Meyering, 2010/10/18
- Re: git format-patch, Bruno Haible, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Paul Eggert, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Paul Eggert, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Bruno Haible, 2010/10/18
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Paul Eggert, 2010/10/19
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Jim Meyering, 2010/10/19
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Paul Eggert, 2010/10/24
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Jim Meyering, 2010/10/25
- Re: [PATCH] inttostr.h: add compile-time buffer overrun checks, Bruno Haible, 2010/10/25