[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:       Simon Baldwin <simonb () google ! com>
Date:       2008-04-04 23:42:37
Message-ID: 47F6BCED.5010000 () google ! com
[Download RAW message or body]

Richard Guenther wrote:
> On Fri, Apr 4, 2008 at 1:07 AM, Simon Baldwin <simonb@google.com> wrote:
>   
>> Attached below is a modest patch to provide a subset of the -Warray-bounds
>>  warnings from tree-vrp.c in the C and C++ front ends.  This permits the
>>  compiler to warn about egregious array bounds violations in unoptimized
>>  compilations or compilations that may use -fno-tree-vrp.  At present, array
>>  bounds checking is only done on optimized compilations.
>>
>>  A side effect of copying these warnings up into the language frontends is
>>  that warnings are now printed even if the array access is in dead or
>>  inaccessible code.
>>
>>  The current array bounds tests are modified to account for this new checking,
>>  and additionally there are two new tests for warnings from -O0 compilations,
>>  one for C and one for C++.
>>
>>  Bootstrapped, and regression tested on i686 Linux for gcc and g++.
>>
>>  Thoughts?  Okay for trunk?
>>     
>
> I think it is a good thing to move these to the frontends.  Did you test
> the warning on some real-world C and C++ code?  I expect some
> "false" positives from deliberately partial dead code coming from
> template instantiation or constant propagation from function arguments.

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.

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

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