Your sample compiles As-Is into my compiler (Solaris on x86), but in fact it is so simple that the platform should not matter. As written, your code should compile and execute everywhere. It would seem that this was some disadvantage of MudFlap.
I do not have access to MudFlap in my current environment, but there is something here that could allow you to avoid the problem altogether:
#include <iostream> #include <boost/shared_ptr.hpp> using namespace std; int main() { boost::shared_ptr<int> var (new int(6)); cout << "Hello #" << *var << endl; return 0; }
I guess that "hiding" dynamic allocation inside smart pointer initialization will fool MudFlap.
I assume that your snippet is a simplification of the real problem. Although I do not know why even a simplified version will not compile in your environment (it should), the above solution has the virtue that you do not need to worry about deleting the pointer, whatever the real reality.
And again, maybe MudFlap is really smart and trying to get you to use RAII. Perhaps it has some configuration setting where you can specify what you want to use and manage the raw pointers. In any case, it would be nice for you to use a smart pointer approach if you like.
Try and let us know if this helps.
source share