This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Add a subset of -Warray-bounds warnings to C/C++ front ends


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]