
Peter Dimov mailto:pdimov@mmltd.net wrote:
Sam Partington wrote:
4511 and 4512 are useless warnings. They are telling you that the copy constructor and assignment operator are inaccessible. Even though you're not trying to call them. [...]
C4127 is also awkward. As it gives warnings for some common idioms. It refers to conditional expressions being constant.
These warnings can be annoying, but they aren't useless. They do find bugs.
I agree that 4127 can help you find bugs. But I can't think of any situation where 4511 or 4512 will help you find a bug. If you actually
Sam Partington wrote: try
to call an inaccesible copy constructor or assignement operator, then the compiler (correctly) fails to compile it.
Thats why I used the word "awkward" rather than "useless" for 4127.
I'll happily be proved wrong though.
I can't recall a specific example at the moment, though I have definitely encountered one several times. The basic idea is that 4511/4512 help you enforce the guideline that a class should always either have a declared copy constructor and an assignment operator, or a comment that says "implicit versions are fine and useful". This guideline _does_ eliminate bugs by forcing programmers to think clearly about the copy semantics of every class that they write. With this in mind, every 4511/4512 indicates a violation of this guideline (because the implicit versions are obviously neither fine nor useful), and many violations are bugs ( the guideline would be useless if this weren't so ;-) ). This guideline is not universally accepted. Some prefer the ": noncopyable" idiom, or some equivalent thereof. If you don't buy it, you will likely find 451[12] useless. Your choice.