<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 30, 2010, at 12:55 PM, William Gropp wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">As long as you have a flat address space, this trick works.  The problem is (was) for systems with memory segments; in that case, &realarray[-1] might not be valid.</div></blockquote><div><br></div>   Bill,</div><div><br></div><div>    So is it then a question of using &something[invalidindex] that is the only problem? We never do this in PETSc; we only do, for example, a -= mstart; that is add or subtract to an already existing valid address. Of course a[0] may now be invalid, but then the code is written so those invalid indices are never used.</div><div><br></div><div>   In other words replace</div><div><br></div><div><span class="Apple-style-span" style="font-family: Times; "><pre>int *array = &realarray[-1];</pre><pre>with </pre><pre><span class="Apple-style-span" style="font-family: Times; white-space: normal; "><pre>int *array = &realarray[0];</pre><pre>array--; now use array[1]</pre><pre>Is the second form any more "valid" or "legal" then the first form? Or are they equally "wrong".</pre><pre><br></pre><pre> Thanks</pre><pre><br></pre><pre>   Barry</pre><pre><br></pre><pre><br></pre></span></pre></span><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Bill</div><div><br><div><div>On Mar 30, 2010, at 12:30 PM, Barry Smith wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>   What do the PETSc developers think of this? Is it "<span class="Apple-style-span" style="font-family: Times; ">otherwise, the behavior is undefined, <em>even if the pointer is not dereferenced</em>."? </span></div><div><font class="Apple-style-span" face="Times"><br></font></div><div><font class="Apple-style-span" face="Times">   Whenever we work with global indices like  in FormFunctionLocal() we do this. </font></div><div><font class="Apple-style-span" face="Times"><br></font></div><div><font class="Apple-style-span" face="Times">    Is PETSc wrong to ever do this? Is there any other way to allow users to work with global indices in a simple way? Do we need to strip out all the FormFunctionLocals() from PETSc? Not the end of the world but it provides such a nice simple interface for simple problems it seems a pity to toss it.</font></div><div><font class="Apple-style-span" face="Times"><br></font></div><div><font class="Apple-style-span" face="Times">   Thanks</font></div><div><font class="Apple-style-span" face="Times"><br></font></div><div><font class="Apple-style-span" face="Times">   Barry</font></div><div><font class="Apple-style-span" face="Times"><br></font></div></div></blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>William Gropp</div><div>Deputy Director for Research</div><div>Institute for Advanced Computing Applications and Technologies</div><div>Paul and Cynthia Saylor Professor of Computer Science</div><div>University of Illinois Urbana-Champaign</div><div><br class="khtml-block-placeholder"></div></div><br class="Apple-interchange-newline"></span></div></span><br class="Apple-interchange-newline"> </div><br></div></div></blockquote></div><br></body></html>