[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: [PATCH][RFC] Add a subset of -Warray-bounds warnings to C/C++ front ends
From:       "Andrew Pinski" <pinskia () gmail ! com>
Date:       2008-04-04 23:50:20
Message-ID: de8d50360804041650x53096430k6c719c7c550e61af () mail ! gmail ! com
[Download RAW message or body]

On Fri, Apr 4, 2008 at 4:42 PM, Simon Baldwin <simonb@google.com> wrote:
>  I tried it on a codebase consisting of more than 3,000 source modules,
> almost all C++.  Encouragingly, it produced no false positives, and only one
> true positive, the latter from a "plant" I'd deliberately placed into the
> code ahead of time just to be sure I'd set up the compilation correctly.

Here is one case where this might break:

#define strlen(a) ({  int len = 0; if(__builtin_constant_p(a)) {if
(!a[0]) len=0; else if (!a[1]) len = 1; else if (!a[2]) len = 2; else
len = realstrlen(a); } else len = realstrlen (a); len;})

This is just a semi fake example (glibc does something like this for
one of the str* functions, I forget which one) where define comes up
with out of bounds array references in dead code.

Thanks,
Andrew Pinski
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic