On Tue, Oct 8, 2013 at 6:17 PM, Jordan Rose <[email protected]> wrote:
> > Richard, I get the feeling that we should have just warned about the > out-of-bounds array access before forming the MemberExpr. What do you think? > > http://llvm-reviews.chandlerc.com/D1580 > I'm not really very happy with the way that CheckArrayAccess is distributed across the code, with calls in a half-dozen places. I'd be surprised if there aren't other ways to sneak an array access in that it won't see. In fact, it failed to catch the very first thing I tried: int arr[10]; int k = static_cast<int>(arr[12]); I'd much prefer an approach that is correct by construction. How about: When we build an array access, check the index against the bound. If it's in bounds, ignore. If it's out of bounds, diagnose. If it's one-past-the-end, add it to a DenseSet on Sema. When we build a unary * or & operator, use that to maintain state on whether we're using the subscript expression for its address or for its value. Likewise when we build a ?: operator. And diagnose any at-bounds indexing when we get to the end of the full-expression.
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
