<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 25, 2015 at 2:48 AM, Stephan Bergmann <span dir="ltr"><<a href="mailto:sbergman@redhat.com" target="_blank">sbergman@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In LibreOffice we have a Clang plugin calling Expr::<u></u>EvaluateAsBooleanCondition, and at least with a recent trunk Clang build with assertions enabled that triggers the assert in<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info) {<br>
  assert(E->isRValue() && E->getType()-><u></u>hasPointerRepresentation());<br>
  return PointerExprEvaluator(Info, Result).Visit(E);<br>
}<br>
</blockquote>
<br>
(in lib/AST/ExprConstant.cpp) on expressions like<br>
<br>
  m_Strings[nEntry]<br>
<br>
where m_Strings is of std::vector type.<br>
<br>
What happens is that Expr::<u></u>EvaluateAsBooleanCondition goes into LValueExprEvaluator::<u></u>VisitArraySubscriptExpr, which calls EvaluatePointer, which asserts because m_Strings doesn't have array or pointer type.<br>
<br>
It's not clear to me where the error lies; should LValueExprEvaluator::<u></u>VisitArraySubscriptExpr even be reached for uses of user-defined operator[] overloads?<br></blockquote><div><br></div><div>No. Are you calling EvaluateAsBooleanCondition on a value-dependent expression, perhaps? We should probably add an assert for that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For now, I'm working around the assertion with<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Index: lib/AST/ExprConstant.cpp<br>
==============================<u></u>==============================<u></u>=======<br>
--- lib/AST/ExprConstant.cpp    (revision 233173)<br>
+++ lib/AST/ExprConstant.cpp    (working copy)<br>
@@ -4647,6 +4647,10 @@<br>
   if (E->getBase()->getType()-><u></u>isVectorType())<br>
     return Error(E);<br>
<br>
+  if (!(E->getBase()->getType()-><u></u>isArrayType() ||<br>
+        E->getBase()->getType()-><u></u>isPointerType()))<br>
+    return false;<br>
+<br>
   if (!EvaluatePointer(E->getBase()<u></u>, Result, Info))<br>
     return false;<br>
<br>
</blockquote>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>