<div dir="ltr">On Mon, Jan 14, 2013 at 11:17 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><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 class="im"><br>
On Jan 14, 2013, at 9:02 AM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
<br>
> The cast macros like PetscBLASIntCast() are not "safe" in that they include two separate statements. Unfortunately, we cannot do better with C89 unless we pass the target as an argument. Regardless, these casts cannot be used in declarations.<br>

><br>
> PetscBLASInt   one = 1,bn = PetscBLASIntCast(xin->map->n);<br>
> PetscErrorCode ierr;<br>
><br>
> This is invalid C89 because once the macro expands, there is a statement before the next declaration. Furthermore, the check calls SETERRQ in case of failure, so it must be inside a PetscFunctionBegin/PetscFunctionReturn block.<br>

><br>
> Should we change this cast to an inline function (or equivalent macro) so that this usage is more explicit?<br>
<br>
</div>  Note that even if you change it to an inline function it still will not give the correct stack frame since it is not inside the PetscFunctionBegin/End.<br>
<br>
  Shouldn't we simply ban its use in the declarations part of the routines? Note that its use in, for example,<br>
<br>
    } else {<br>
      PetscBLASInt ione = 1;<br>
      PetscScalar aone = 1.0, azero = 0.0;<br>
      PetscBLASInt neqs = PetscBLASIntCast(bcgsl->ell-1);<br>
<br>
is legal since it is within a PetscBegin/Return block and the last declaration given.<br>
<br>
A quick etags search found that it is being used correctly already almost anywhere. The suspicious place is only in the documentation :-)<br>
<br>
Thus I say, fix the documentation and check that it is never used incorrectly but don't change its form.</blockquote><div><br></div><div style>I completely disagree. This is very misleading. Something named *Cast() which does not actually behave as a cast,</div>
<div style>and only breaks on some compilers? Are we purposely trying to confuse new developers?</div><div style><br></div><div style>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
  Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> Regardless, Satish, can you set up a build --with-64-bit-indices CFLAGS='-std=c89 -pedantic -Wno-long-long'?<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>