[PATCH] Fix to PR5683 - issue diagnostic for pointer subtraction with type of size zero.

Richard Smith richard at metafoo.co.uk
Sun Apr 7 19:20:23 PDT 2013



================
Comment at: lib/Sema/SemaExpr.cpp:6735
@@ +6734,3 @@
+        CharUnits ElementSize = Context.getTypeSizeInChars(rpointee);
+        if (ElementSize.isZero() && rpointee.getTypePtr()->isStructureType()) {
+            Diag(Loc,diag::err_sub_ptr_zero_size_types)
----------------
Why do you need the second check here? Any time the pointee has size zero, the pointer subtraction will divide by zero, right?


http://llvm-reviews.chandlerc.com/D637



More information about the cfe-commits mailing list