<div dir="ltr"><div>In clang's lib/AST/ExprConstant.cpp, it seems that we always return 0 if our offset from the object's start is negative (or if the offset is greater than the size of the object). I think this behavior is sane, and that it would be odd if LLVM and clang acted differently here, so I'd just hand back 0 bytes if our offset is negative.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 28, 2016 at 3:29 AM, Strahinja Petrovic <span dir="ltr"><<a href="mailto:strahinja.petrovic@rt-rk.com" target="_blank">strahinja.petrovic@rt-rk.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">spetrovic added a comment.<br>
<br>
Ok, I will resolve offset problem in this revision. Handling Phis will be different patch after this is committed.<br>
So, I have question about offset problem. For this  example:<br>
<span><br>
int foo(int N) {<br>
<br>
  char Small[10];<br>
  char Large[20];<br>
<br>
</span>  char *Ptr = N ? Small : Large - 19;<br>
  return __builtin_object_size(Ptr,0);<br>
<br>
}<br>
<br>
int main() {<br>
<br>
  size_t ret;<br>
  ret = foo(0);<br>
  printf("\n%d\n", ret);<br>
  return 0;<br>
<br>
}<br>
<br>
gcc gives 39 as result, I don't think that is correct value, what is your opinion about this case and similar cases ?<br>
<div><div><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D18438" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18438</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div></div>