[intrusive] Problem with EDG base compilers in strict Ansi mode.

Hello, currently any_test and doc_any_hook fail on Tru64/CXX with the following errors: cxx: Error: ../boost/intrusive/detail/any_node_and_algorithms.hpp, line 276: class template "boost::intrusive::any_algorithms<VoidPointer>" has no member "unlink_not_available_for_any_hooks" (notmember) any_algorithms<VoidPointer>::unlink_not_available_for_any_hooks(); -----------------------------------^ cxx: Error: ../boost/intrusive/detail/any_node_and_algorithms.hpp, line 283: class template "boost::intrusive::any_algorithms<VoidPointer>" has no member "swap_nodes_not_available_for_any_hooks" (notmember) any_algorithms<VoidPointer>::swap_nodes_not_available_for_any_hooks(); -----------------------------------^ AFAICT this is the only EDG based compiler which tests in strict Ansi mode, adding -strict_ansi to the other EDG based compilers (acc for example) would probably lead to the same error. Attached patch contains a proposed fix for this. It checks for __EDG__ and __STD_STRICT_ANSI to enable the fix and works for me locally. The patch should replace the compile error by a link error, because in strict Ansi mode EDG doesn't allow you to refer to non-existing names. OK to apply? Regards, Markus Index: detail/any_node_and_algorithms.hpp =================================================================== --- detail/any_node_and_algorithms.hpp (revision 46676) +++ detail/any_node_and_algorithms.hpp (working copy) @@ -269,6 +269,11 @@ static bool unique(const_node_ptr node) { return 0 == node->node_ptr_1; } + +#if defined(__EDG__) && defined(__STD_STRICT_ANSI) + static void unlink(node_ptr); + static void swap_nodes(node_ptr l, node_ptr r); +#else static void unlink(node_ptr) { //Auto-unlink hooks and unlink() call for safe hooks are not @@ -282,6 +287,7 @@ //what algorithm they must use from unlink them from the container any_algorithms<VoidPointer>::swap_nodes_not_available_for_any_hooks(); } +#endif }; } //namespace intrusive

Markus Schöpflin wrote:
Hello,
currently any_test and doc_any_hook fail on Tru64/CXX with the following errors:
cxx: Error: ../boost/intrusive/detail/any_node_and_algorithms.hpp, line 276: class template "boost::intrusive::any_algorithms<VoidPointer>" has no member "unlink_not_available_for_any_hooks" (notmember) any_algorithms<VoidPointer>::unlink_not_available_for_any_hooks(); -----------------------------------^ cxx: Error: ../boost/intrusive/detail/any_node_and_algorithms.hpp, line 283: class template "boost::intrusive::any_algorithms<VoidPointer>" has no member "swap_nodes_not_available_for_any_hooks" (notmember)
any_algorithms<VoidPointer>::swap_nodes_not_available_for_any_hooks(); -----------------------------------^
AFAICT this is the only EDG based compiler which tests in strict Ansi mode, adding -strict_ansi to the other EDG based compilers (acc for example) would probably lead to the same error.
Attached patch contains a proposed fix for this. It checks for __EDG__ and __STD_STRICT_ANSI to enable the fix and works for me locally.
The patch should replace the compile error by a link error, because in strict Ansi mode EDG doesn't allow you to refer to non-existing names.
OK to apply?
Please, go ahead. I just want to get a compilation error when this funcion is called, but with gcc 4.3 BOOST_STATIC_ASSERT((false)) is instantiated even if the function is called (other compilers just are fine). If this is changed to a linking error, is better than a run-time error. If you have any idea for this, let me know. Regards, Ion

Ion Gaztañaga wrote:
Please, go ahead. I just want to get a compilation error when this funcion is called, but with gcc 4.3 BOOST_STATIC_ASSERT((false)) is instantiated even if the function is called (other compilers just are
I meant "if the function is NOT called". Regards, Ion

Ion Gaztañaga wrote:
Markus Schöpflin wrote:
[...]
The patch should replace the compile error by a link error, because in strict Ansi mode EDG doesn't allow you to refer to non-existing names.
OK to apply?
Please, go ahead. I just want to get a compilation error when this funcion is called, but with gcc 4.3 BOOST_STATIC_ASSERT((false)) is instantiated even if the function is called (other compilers just are fine). If this is changed to a linking error, is better than a run-time error. If you have any idea for this, let me know.
OK, I applied the patch. You might want to massage the comment a bit, and probably extend the condition to include GCC 3.4 as well. I also tried using BOOST_STATIC_ASSERT(false) but I also get the compile error, so I have no other idea besides turning the compile time error into a link time error. BTW, I think there is no test (expected-to-fail) which actually checks that your helpful catch-all code is actually working as expected. But now you would need two tests anyway, depending on the compiler. I don't know if this is supported by Boost.Build out of the box. Regards, Markus

Markus Schöpflin wrote:
OK, I applied the patch. You might want to massage the comment a bit, and probably extend the condition to include GCC 3.4 as well.
Applied also to the release branch. Regards, Ion

Markus Schöpflin wrote:
OK, I applied the patch. You might want to massage the comment a bit, and probably extend the condition to include GCC 3.4 as well.
This should of course refer to GCC 4.3, not 3.4. Markus

Markus Schöpflin wrote:
Markus Schöpflin wrote:
OK, I applied the patch. You might want to massage the comment a bit, and probably extend the condition to include GCC 4.3 as well.
This enable_if trick works for GCC 4.3. Could you try it with EDG? Modify boost/trunk/boost/intrusive/detail/any_node_and_algorithms.hpp: [...] #include <boost/intrusive/detail/mpl.hpp> [...] template<class VoidPointer> class any_algorithms { public: template <class T> static void function_not_available_for_any_hooks(typename detail::enable_if<detail::is_same<T, bool> >::type) {} public: [...] static void unlink(node_ptr) { //Auto-unlink hooks and unlink() call for safe hooks are not //available for any hooks!!! any_algorithms<VoidPointer>::template function_not_available_for_any_hooks<node_ptr>(); } static void swap_nodes(node_ptr l, node_ptr r) { //Any nodes have no swap_nodes capability because they don't know //what algorithm they must use from unlink them from the container any_algorithms<VoidPointer>::template function_not_available_for_any_hooks<node_ptr>(); } Ion

Sorry for the late reply, I have been away for two weeks... Ion Gaztañaga wrote:
This enable_if trick works for GCC 4.3. Could you try it with EDG?
Your enable_if trick works with CXX in strict ansi mode, so it should work with the other EDG based compilers as well. Markus

Markus Schöpflin wrote:
Your enable_if trick works with CXX in strict ansi mode, so it should work with the other EDG based compilers as well.
Markus
Thanks! Already merged to the release branch. Regards, Ion
participants (2)
-
Ion Gaztañaga
-
Markus Schöpflin