#1821: Carpet may call object methods with this == NULL -----------------------+---------------------------------------------------- Reporter: rhaas | Owner: eschnett Type: defect | Status: reopened Priority: optional | Milestone: Component: Carpet | Version: development version Resolution: | Keywords: -----------------------+----------------------------------------------------
Comment (by rhaas):
(1) I don't think that CarpetLib itself calls this method, so the
changes to {{{ggf.cc}}} should not be necessary.
I added a comment to the code diff: https://bitbucket.org/eschnett/carpet/pull-requests/7/carpet-avoid-using- null-pointer-for-member/diff#comment-33242870
(2) In {{{PeriodicCarpet}}}, you could use {{{src}}} instead of
{{{fake_data_pointer()}}}. Could be done. That seems odd though.
(3) The initialization of the static variable in {{{fake_data_pointer}}}
is not thread-safe. This has actually become an issue when using Qthreads for parallelization. Correct. At the time I reported this CarpetLib was not yet thread safe (ie none of the Timers was) so it did not matter. Thread safe would be either using new() or the src trick that you suggest or making transfer_from a static member function that takes the current dst as eg its first argument.