[multi_index] Warnings with level 4 on Microsoft compiler

I compile my program which uses Boost.multi_index and get some obscure warnings. It would be great if the library maintainer could disable them in the source code - it is really annoying and I would like to bracker my #include <boost/...> with #pragma-s. The warnings are: boost\multi_index\detail\hash_index_node.hpp(89) : warning C4610: struct 'boost::multi_index::detail::hashed_index_node_trampoline<Super>' can never be instantiated - user defined constructor required boost\multi_index\composite_key.hpp(570) : warning C4512: 'boost::multi_index::composite_key_result<CompositeKey>' : assignment operator could not be generated boost\multi_index\detail\bucket_array.hpp(152) : warning C4512: 'boost::multi_index::detail::bucket_array<Allocator>' : assignment operator could not be generated The line numbers are against 1.33.1 release.

Alexei Alexandrov <alexei.alexandrov <at> gmail.com> writes:
I compile my program which uses Boost.multi_index and get some obscure warnings. It would be great if the library maintainer could disable them in
the
source code - it is really annoying and I would like to bracker my #include <boost/...> with #pragma-s.
A correction: of course, I would _not_ like to bracket my #includes with #pragma warning-s. P.S. Kudos to the author of multi_index - it's really great thing. Your mother must be very proud of you...

Alexei Alexandrov ha escrito:
I compile my program which uses Boost.multi_index and get some obscure warnings. It would be great if the library maintainer could disable them in the source code - it is really annoying and I would like to bracker my #include <boost/...> with #pragma-s.
The warnings are:
boost\multi_index\detail\hash_index_node.hpp(89) : warning C4610: struct 'boost::multi_index::detail::hashed_index_node_trampoline<Super>' can never be instantiated - user defined constructor required
boost\multi_index\composite_key.hpp(570) : warning C4512: 'boost::multi_index::composite_key_result<CompositeKey>' : assignment operator could not be generated
boost\multi_index\detail\bucket_array.hpp(152) : warning C4512: 'boost::multi_index::detail::bucket_array<Allocator>' : assignment operator could not be generated
The line numbers are against 1.33.1 release.
Hello Alexei, I could avoid these warnings in Boost.MultiIndex, but I'm not sure this is the right thing to do, as the problem is really Boost-wide and should be considered, IMHO, from a global point of view: any class using boost::noncopyable will make MSVC level 4 shout, try the following for instance: #include <boost/noncopyable.hpp> class foo:boost::noncopyable { }; In my opinion, these warnings can hardly uncover any real programming error (which is what the warnings are meant for in the first place), so it would be perfectly safe to just pragma them away globally in your project.
P.S. Kudos to the author of multi_index - it's really great thing. Your mother must be very proud of you...
She is, though she doesn't care much about C++ :) Thanks for your compliments, best regards, Joaquín M López Muñoz Telefónica, Inevstigación y Desarrollo

Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
I could avoid these warnings in Boost.MultiIndex, but I'm not sure this is the right thing to do, as the problem is really Boost-wide and should be considered, IMHO, from a global point of view: any class using boost::noncopyable will make MSVC level 4 shout, try the following for instance:
The example you provided compiles without a warning with "cl -c -W4 test.cpp". So the problem is somewhat more specific perhaps?

Alexei Alexandrov ha escrito:
JoaquÃn Mª López Muñoz <joaquin <at> tid.es> writes:
I could avoid these warnings in Boost.MultiIndex, but I'm not sure this is the right thing to do, as the problem is really Boost-wide and should be considered, IMHO, from a global point of view: any class using boost::noncopyable will make MSVC level 4 shout, try the following for instance:
The example you provided compiles without a warning with "cl -c -W4 test.cpp".
Ummm... it shows C4511 and C4512 in MSVC 6.5. Maybe MSVC 7.1 is smarter.
So the problem is somewhat more specific perhaps?
The problem is, one way or another, related to the noncopyable idiom (deriving from a class with private copy ctr and assignment operator.) Maybe the following, more convoluted snippet will MSVC 7.1 emit the warning: #include <boost/noncopyable.hpp> class bar:boost::noncopyable { }; template<typename T> class foo:bar { public: foo(int x=0); }; foo<int> f; Even it doesn't, my point remains that this is a problem likely to be distributed across the whole Boost codebase. And that it is IMHO a nonsense warning, since lacking automatically generated copy ctor and assignment operator cannot AFAICS lead to inadvertent errors. Joaquín M López Muñoz Telefónica, Inevstigación y Desarrollo

Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
The problem is, one way or another, related to the noncopyable idiom (deriving from a class with private copy ctr and assignment operator.) Maybe the following, more convoluted snippet will MSVC 7.1 emit the warning:
#include <boost/noncopyable.hpp>
class bar:boost::noncopyable { };
template<typename T> class foo:bar { public: foo(int x=0); };
foo<int> f;
Well, it does now. Thanks for this. I will suggest a patch for these warnings into boost MSVC compiler config so that all libraries can benefit from this. But what about boost\multi_index\detail\hash_index_node.hpp(89) : warning C4610: struct 'boost::multi_index::detail::hashed_index_node_trampoline<Super>' can never be instantiated - user defined constructor required This warning seems to have more sense and should not be disabled perhaps. Do you think it should be disabled on whole Boost level as well?

Alexei Alexandrov ha escrito:
JoaquÃn Mª López Muñoz <joaquin <at> tid.es> writes:
The problem is, one way or another, related to the noncopyable idiom (deriving from a class with private copy ctr and assignment operator.) Maybe the following, more convoluted snippet will MSVC 7.1 emit the warning:
#include <boost/noncopyable.hpp>
class bar:boost::noncopyable { };
template<typename T> class foo:bar { public: foo(int x=0); };
foo<int> f;
Well, it does now. Thanks for this. I will suggest a patch for these warnings into boost MSVC compiler config so that all libraries can benefit from this. But what about
boost\multi_index\detail\hash_index_node.hpp(89) : warning C4610: struct 'boost::multi_index::detail::hashed_index_node_trampoline<Super>' can never be instantiated - user defined constructor required
This warning seems to have more sense and should not be disabled perhaps. Do you think it should be disabled on whole Boost level as well?
Hello again, Alexei, I've commited changes to the CVS (trunk and release branch) so that C4610 warnings are no longer emitted by MSVC in level 4 warning mode. I'd appreciate if you could download a CVS copy (for instance, from http://www.boost-consulting.com/boost.tar.bz2) and verify that these warnings have actually gone away in MSVC 7.1. Warnings C4511 and C4512 will continue to appear, though. Best regards, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Alexei Alexandrov
-
Joaquín Mª López Muñoz