[petsc-dev] Problem with PETSC_NULL and variadic functions

Dmitry Karpeev karpeev at mcs.anl.gov
Thu Nov 10 09:18:27 CST 2011


On Thu, Nov 10, 2011 at 9:14 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> On Thu, Nov 10, 2011 at 08:23, Matthew Knepley <knepley at gmail.com> wrote:
>
>> No one thinks arrays are easier, however variadic functions are not
>> interoperable, and it seems they can fail in
>> weird ways even for C++. In my book, that is "not robust".
>>
>
> Format strings would make it explicit how many parameters you expected.
> You could also specify global versus ghosted independently for each entry.
>

Besides the number of arguments, there is the issue of them being passed on
the stack, as I (sort of) understand.
The format string would tell us what type each argument is supposed to be,
so that the args can be cast correctly inside the called function.  Is that
right?

>
> Even without the issues of passing NULL as a pointer, I'm concerned about
> using variadic functions without any other indication of the expected
> number of entries because of what happens if you add a DM to the
> DMComposite, but forget to update every call site to match.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20111110/1c5683b3/attachment.html>


More information about the petsc-dev mailing list