[cfe-dev] Pointer arithmetic

Chris Lattner clattner at apple.com
Sun Dec 9 14:10:47 PST 2007


On Dec 9, 2007, at 4:38 AM, Sanghyeon Seo wrote:

> The following error is not diagnosed.
>
> int test(int *a, double *b) { return a - b; }

Yep, as it turns out, we were completely missing the requires sema  
checks for pointer subtraction.  I implemented these here:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20071203/003235.html

> By the way, this does crash in CodeGen. Can CodeGen assume that the
> code is correctly typed, or is it still a good idea to sprinkle
> asserts in CodeGen?

CodeGen can assume that Sema reported no errors, but it has to  
tolerate code that only produces warnings.

-Chris



More information about the cfe-dev mailing list