================
Comment at: lib/AST/ExprConstant.cpp:6564-6570
@@ -6563,1 +6563,9 @@
+ // As an extension, a type may have zero size (empty struct or union in
+ // C, array of zero length). Meaning of pointer difference in such
+ // case is unspecified.
+ if (ElementSize.isZero()) {
+ Result = APValue(Info.Ctx.MakeIntValue(0, E->getType()));
+ return true;
+ }
+
----------------
Should we really treat the result as a constant zero in this case? GCC treats
it as non-constant (and emits a divide-by-zero at runtime.) C++11 requires us
to treat expressions with undefined behavior as non-constant.
http://llvm-reviews.chandlerc.com/D637
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits