[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:       Mark Mitchell <mark () codesourcery ! com>
Date:       2008-04-08 19:20:42
Message-ID: 47FBC58A.5020702 () codesourcery ! com
[Download RAW message or body]

Richard Guenther wrote:

>>  Thoughts?  Okay for trunk?
> 
> I think it is a good thing to move these to the frontends. 

Me too!  The code all looks good.  However, I do think this should be 
factored into a function in c_common.

Also:

+              if (min_index && TREE_CODE (min_index) == INTEGER_CST
+                  && tree_int_cst_lt (idx, min_index))
+                {
+                  warning (OPT_Warray_bounds,
+                           "array subscript is below array bounds");

could do with a better error message.  In C/C++, the min_index is (I 
believe) always zero.  I think you're right to have written the test in 
terms of min_index (future-proofing!), but I think we should special 
case the message.  If the idx is negative and the min_index is zero, say:

   "array subscript is negative"

That's more obvious to the average user.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
[prev in list] [next in list] [prev in thread] [next in thread] 

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