Is the problem that we might be using more registers than might be necessary in a variadic function call?<br><br><div class="gmail_quote">On Wed, Nov 9, 2011 at 2:26 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">#define PETSC_NULL           0<div><br></div><div>This is an "int" value, though it's special in that it will be implicitly converted to a null pointer (not even necessary bitwise 0, according to the standard) if its value is assigned to a pointer. If we pass it to a function with unspecified arguments (e.g. variadic), then it will be passed as an int.</div>


<div><br></div><div>We usually use PETSC_NULL in place of a pointer value. It is common for an entire pointer-length integer register to be used when passing an "int". Most architectures pass the first few arguments in registers before passing on the stack. We seem to be getting lucky so far in that we haven't used functions like DMCompositeGetAccess() on systems where sizeof(void*) != sizeof(int), with more arguments than are passed in registers.</div>


<div><br></div><div>C99 has stddef.h define NULL to be a null pointer constant ((void*)0). This is not compatible with C++ and I don't see a simple resolution.</div><div><br><div>It doesn't work in C++ because there is no implicit pointer conversion from void*. So instead of having a pointer-valued NULL like in C, they define NULL to be 0 or 0L, which is just an integer (unless assigned to a pointer in which case 0 is special and is converted implicitly).</div>


<div><br></div><div>Since it was 2011 and there was still no way to define a null pointer in C++, the new standard C++11 introduces a new keyword nullptr. Considering that we are still not allowed to use C99 in PETSc, it seems unlikely that we would be allowed to rely on C++11 which is less than two months old.</div>


<div><br></div><div><br></div><div>We could pass a "format string" indicating which entries we were actually requesting. Other ideas?</div></div>
</blockquote></div><br>