[bind10-dev] what to do for MSVC 4512 warnings?
Michal 'vorner' Vaner
michal.vaner at nic.cz
Mon Jul 2 07:51:56 UTC 2012
Good morning
On Sun, Jul 01, 2012 at 09:18:56AM +0000, Francis Dupont wrote:
> You can resolve the C4512 warning for this code in one of three ways:
> - Explicitly define an assignment operator for the class.
I think this is not exactly what we want. If we didn't have a problem with this
yet, it means we don't want to assign to the class. Anyway, I think it would
make little sense anyway, because, what would the operator do? The class is
meant to be imutable.
> - Remove const from the data item in the class.
That is probably a bad idea.
> I tried the first but it is very painful (a lot of spurious changes
> in far too many files), the second is not available, the third works
> well (I added a '#pragma warning(disable: 4512)' at the end of config.h)
> but IMHO it is a bad idea to disable a warning by laziness (BTW there
> is no way to disable a warning by compiler config/argument as it is
> done, including in case it should not, for Unix compilers).
I'm not sure it is laziness. I don't see other reasonable solution. I mean, such
class does act little bit strangely, but if it is the behaviour we want… And it
shouldn't cause any kind of runtime breakage, if anyone hits a problem with
this, it would be a compile-time problem.
> I propose a fourth way, IMHO far better: to make all impacted
> class (and struct) declarations derived from boost::noncopyable
That is, IMO, a bad idea that would probably not work in many cases. This does
disallow a copy constructor as well (which works, even when there are the const
members). That would make it not possible to return an object of the class from
any method, as the copy constructor is used on the return value.
With regards
--
Anyone seen smoking will be considered on fire and will be put out immediately.
Michal 'vorner' Vaner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://lists.isc.org/pipermail/bind10-dev/attachments/20120702/9510ea3e/attachment.bin>
More information about the bind10-dev
mailing list