|
Boost : |
Subject: [boost] [new Warnings policy] MS C4180 on the Maintenance Guidelines
From: Patrick Horgan (phorgan1_at_[hidden])
Date: 2009-11-16 16:08:50
First, I have to say, amazing job, and amazing reference. I don't believe
that there's anything else like this on the web.
Now just some thoughts. N.B. my assumption is that getting rid of the
warning with code changes that don't obfuscate meaning is preferred to
suppressing.
Suggestion column:
I would prefer that the this column tell me how to write my code
differently to avoid the warning if possible. The Suppression column does
a good job of telling me how to suppress.
Suppression column:
Wonderful!
C4180 Surely instead of suggesting suppressing you would remove the
meaningless qualifier?
C4996 Microsoft deprecated these functions on their own (and they call
themselves POSIX compliant), and replaced them with extremely dangerous
replacements that they claim are safe. The replacement functions are
non-POSIX and aren't available from other compilers, hence non-portable.
These warnings should be suppressed. I believe that you can also suppress
by defining _CRT_NONSTDC_NO_DEPRECATE before and undef'ing after to do a
local suppression.
C4800 Might suggest that they use a bool valued expression in the first
place, i.e. instead of foo, foo!=0, or do a static cast to bool. This is at
times indicative of real bugs, when people turn out to not be doing what
they thought they were doing. Apparently this is one of my favorite bugs
(by favorite I don't mean that I like it either!)
C4506 Might suggest that they provide the definition;)
Someone had mentioned a redesign of boost:noncopyable to work around the
C4511 and C4512 warnings from deriving from boost:noncopyable. Is anyone
looking into it? Is it even possible? It's a shame that this wonderful
thing generates so much noise. If course, if you want to make a class
uncopyable, rather than inheriting from boost:uncopyable, you could just
make your own copy and assignment declarations privately and without
definitions if you don't need them. It makes the class non-copyable without
generating the warnings. If you have other causes of C451{0-2} see below:
C4510/C4511/C4512 In general if you provide one of destructor, assignment
operator, and copy constructor, then you need all three. The best fix is to
provide the method. Providing a private declaration is a way of telling the
compiler that you are sure your case is different--if it really is. These
are all caused by either inaccessible base class version, or const or
reference data members.
Similar to 4511 and 4512 are the following which occur on trying to derive
from a non-copyable class, i.e. one with the preceding issues--you will also
get 4511 and 4512.
C4625: copy constructor could not be generated because a base class copy
constructor is inaccessible
C4626: assignment operator could not be generated because a base class
assignment operator is inaccessible
C4701 Initialize the variable. (Does it give this warning for volatile? If
it does it's a bug in the compiler. But you would need to suppress in that
case.)
C4702 If the code is really unreachable delete it.
C4535 Does it give this warning even when /EHa is used? You mean that
they're telling you to use something you are using? Wish I had Visual C++
here right now to try this one. It's a bug against the compiler if so. If
/EH is not being used, it will cause memory leaks, so its use should be
added to the tests of things that use this. I would suppress only if /EHa
is used and warnings still printed.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk