[Scummvm-devel] The Curious Case of NonCopyable
Max Horn
max at quendi.de
Fri May 1 14:24:01 CEST 2009
Hi Matt, all,
I have nothing against code analysis tools, not at all. However, their
output certainly needs to be interpreted and viewed in context. And
after two mails of you, I still have no idea what the actual problem
is you perceive here :-). What you think could go wrong, under which
circumstance. My only guess is that you might be saying that somebody
could subvert NonCopyable by subclassing one of the classes which are
supposed to be non-copyable and overloading the copy constructor and
assignment operator. But since of course in C++ you can always shoot
yourself in the foot if you try hard enough, I guess you meant
something else. But what?
Sorry, but output of a tool (or a list of warnings by GCC) is *not* by
itself an explanation as to why there is a problem :-). Concrete code
that looks fine but actually results in incorrect or unexpected
behavior is what I consider an example.
To give an example of an example ;):
PluginManager *pm;
pm = new PluginManager();
*pm = PluginManager::instance();
pm = new PluginManager(PluginManager::instance());
All three attempts to copy a PluginManager instance cause a compile-
time error (not just link-time, as your initial post seemed to suggest).
Now, you seem to see a way how this "protection" could be circumvented
by accident. OK, bad, but how? Please explain.
Bye,
Max
More information about the Scummvm-devel
mailing list