
Richard Webb wrote:
Kevin Scarr
writes: My code compiles, and appears to work fine, however, I am always nervous about these kinds of warnings because I suspect there is something waiting to bite me. I guess I am concerned as to what in my code is causing the compiler to want to generate assignment operators.
Are these warnings symptomatic of a basic mistake I am making? I know that you can't see the code, so this is only a general question. If people think this might be a real problem, I am happy to try to make a small code snippet to illustrate the problem.
The ASIO warning you're seeing is because the struct in question (auto_work) has a reference as a member. VC8/9 produce loads of similar warnings on Boost code. They cause a lot of noise, but don't seem to cause any real problems.
Actually I'm pretty annoyed that these warnings are generated by the compiler at all: as far as I can see they can never represent a true programming error - though I stand to be corrected on that one! The warnings are raised when a class or structure does *not* have an explicit copy-constructor or assignment operator declared, *and* one could not be generated automatically by the compiler. However, the warnings are issued even though neither the copy-constructor nor the assignment operator are ever used - if they were used then you would get a compiler error. One possible fix is to declare but not define a private copy constructor and assignment operator (rather like boost::noncopyable), but given that those definitions are never used, this is just syntactic sugar to shut the compiler up. BTW if I remember correctly you get the same warnings if you declare a class that inherits from noncopyable which rather destroys the whole point of that one :-( Tellingly, as far as I know VC++ is the only compiler to issue this warning. HTH, John.