<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><br><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
I do not think a negative index for struct field indexing is valid.<br></blockquote><div><br></div></span><div>You are incorrect :)<br></div></div></div></div></blockquote><div><br></div><div>FWIW, this is a common mistake.</div><div>Please remember that LLVM level structs and GEP do not have the same rules and pretty much no relation to C-level structs.</div><div><br></div><div>GEP is just an indexing operation. Unlike C, i can form pointers to wherever i want, and even if i mark them inbounds, your only guarantee is that they are in the object somewhere, you have no guarantee on whether i use positive or negative gep indices to generate those pointers and either way is just as valid.</div><div>As mentioned, there are plenty of cases frontends will generate negative gep indices for normal source level field accesses of C-level structs.</div><div><br></div></div></div></div>