[shared_array] Conflict with Boost.TR1

Not sure what we can do about this but: #include <boost/shared_array.hpp> doesn't compile when Boost.TR1 is added to the include path. We've been through this before with shared_ptr.hpp and a solution was found, any chance of some magic here as well? The alternative is for all the shared_ptr/shared_array code to include <boost/config/no_tr1/memory.hpp> rather than <memory> directly. In fact the latter option is probably easier to maintain in the long run: the problem is sporadic, hard to reproduce (because it depends upon which headers are included and in which order), and even harder to track down :-( Sorry, but there ain't no easy way.... Thanks, John Here are the compiler errors: gcc-C++-action ../../../bin/boost/libs/tr1/test/std_test_boost.test/gcc/debug/st d_test_boost.o In file included from /cygdrive/c/data/boost/develop/boost/boost/tr1/memory.hpp: 56, from /cygdrive/c/data/boost/develop/boost/boost/tr1/tr1/memory: 28, from /cygdrive/c/data/boost/develop/boost/boost/detail/shared_c ount.hpp:32, from /cygdrive/c/data/boost/develop/boost/boost/shared_array.hp p:26, from /cygdrive/c/data/boost/develop/boost/libs/tr1/test/test_bo ost.cpp:10: /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:423: error: field `pn' has incomplete type /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr()': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:144: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(Y*)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:149: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:151: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:151: error: (Each unde clared identifier is reported only once for each function it appears in.) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(Y*, D)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:160: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:162: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(Y*, D, A)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:167: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:169: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `b oost::shared_ptr<T>& boost::shared_ptr<T>::operator=(const boost::shared_ptr<T>& )': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:180: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(const boost::weak_ptr<Y>&)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:187: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(const boost::shared_ptr<Y>&)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:194: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(const boost::shared_ptr<Y>&, boost::detail::static_c ast_tag)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:199: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(const boost::shared_ptr<Y>&, boost::detail::const_ca st_tag)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:204: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(const boost::shared_ptr<Y>&, boost::detail::dynamic_ cast_tag)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:209: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:213: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(const boost::shared_ptr<Y>&, boost::detail::polymorp hic_cast_tag)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:218: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(std::auto_ptr<_Tp1>&)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:229: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:232: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In constructor `boost ::shared_ptr<T>::shared_ptr(Ap, typename boost::detail::sp_enable_if_auto_ptr<Ap , int>::type)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:239: error: class `boo st::shared_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:242: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `b oost::shared_ptr<T>& boost::shared_ptr<T>::operator=(const boost::shared_ptr<Y>& )': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:257: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `b ool boost::shared_ptr<T>::unique() const': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:385: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `l ong int boost::shared_ptr<T>::use_count() const': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:390: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `v oid boost::shared_ptr<T>::swap(boost::shared_ptr<T>&)': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:396: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `b ool boost::shared_ptr<T>::_internal_less(const boost::shared_ptr<Y>&) const': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:401: error: `pn' undec lared (first use this function) /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp: In member function `v oid* boost::shared_ptr<T>::_internal_get_deleter(const std::type_info&) const': /cygdrive/c/data/boost/develop/boost/boost/shared_ptr.hpp:406: error: `pn' undec lared (first use this function) In file included from /cygdrive/c/data/boost/develop/boost/boost/tr1/memory.hpp: 57, from /cygdrive/c/data/boost/develop/boost/boost/tr1/tr1/memory: 28, from /cygdrive/c/data/boost/develop/boost/boost/detail/shared_c ount.hpp:32, from /cygdrive/c/data/boost/develop/boost/boost/shared_array.hp p:26, from /cygdrive/c/data/boost/develop/boost/libs/tr1/test/test_bo ost.cpp:10: /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: At global scope: /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:168: error: field `pn' h as incomplete type /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In constructor `boost:: weak_ptr<T>::weak_ptr()': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:39: error: class `boost: :weak_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In constructor `boost:: weak_ptr<T>::weak_ptr(const boost::weak_ptr<Y>&)': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:64: error: class `boost: :weak_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In constructor `boost:: weak_ptr<T>::weak_ptr(const boost::shared_ptr<Y>&)': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:70: error: class `boost: :weak_ptr<T>' does not have any field named `pn' /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `boo st::weak_ptr<T>& boost::weak_ptr<T>::operator=(const boost::weak_ptr<Y>&)': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:80: error: `pn' undeclar ed (first use this function) /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `boo st::weak_ptr<T>& boost::weak_ptr<T>::operator=(const boost::shared_ptr<Y>&)': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:88: error: `pn' undeclar ed (first use this function) /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `lon g int boost::weak_ptr<T>::use_count() const': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:125: error: `pn' undecla red (first use this function) /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `boo l boost::weak_ptr<T>::expired() const': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:130: error: `pn' undecla red (first use this function) /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `voi d boost::weak_ptr<T>::swap(boost::weak_ptr<T>&)': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:141: error: `pn' undecla red (first use this function) /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `voi d boost::weak_ptr<T>::_internal_assign(T*, const boost::detail::shared_count&)': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:147: error: `pn' undecla red (first use this function) /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp: In member function `boo l boost::weak_ptr<T>::_internal_less(const boost::weak_ptr<Y>&) const': /cygdrive/c/data/boost/develop/boost/boost/weak_ptr.hpp:152: error: `pn' undecla red (first use this function) "g++" -c -DTEST_STD_HEADERS=1 -g -O0 -fno-inline -Wall -ftemplate-depth-25 5 -I"/cygdrive/c/data/boost/develop/boost/boost/tr1/tr1" -I"/cygdrive/c/data/boo st/develop/boost" -I "/cygdrive/c/data/boost/develop/boost" -o "../../../bin/bo ost/libs/tr1/test/std_test_boost.test/gcc/debug/std_test_boost.o" "/cygdrive/c/d ata/boost/develop/boost/libs/tr1/test/test_boost.cpp"

Peter Dimov wrote:
John Maddock wrote:
Not sure what we can do about this but:
#include <boost/shared_array.hpp>
doesn't compile when Boost.TR1 is added to the include path.
The above compiles for me.
... but I committed a "speculative" fix nonetheless. I also fixed function.hpp. As for there being no easy way... of course there is, never add boost.tr1 to the include path; use #include <tr1/functional> instead. Yes, yes, I know, <functional> is what TR1 says. But - having the benefit of hindsight - we can now say with almost 100% certainty that TR1 is wrong, wrong, and wrong, in that order. :-)

Peter Dimov wrote:
... but I committed a "speculative" fix nonetheless. I also fixed function.hpp.
Confirmed: both gcc and Borland are passing those tests now. Can you push those changes onto the release branch as well? Many thanks!
As for there being no easy way... of course there is, never add boost.tr1 to the include path; use #include <tr1/functional> instead. Yes, yes, I know, <functional> is what TR1 says. But - having the benefit of hindsight - we can now say with almost 100% certainty that TR1 is wrong, wrong, and wrong, in that order. :-)
Ah, the old: "if you want to get to there, don't start from here" trick :-) John.

John Maddock wrote:
Peter Dimov wrote:
... but I committed a "speculative" fix nonetheless. I also fixed function.hpp.
Confirmed: both gcc and Borland are passing those tests now. Can you push those changes onto the release branch as well? Many thanks!
My changes to bind and function qualify as new features, so they shouldn't go into the RC branch. The shared_array change is a bug fix, but I need a failing test first.

Peter Dimov wrote:
The shared_array change is a bug fix, but I need a failing test first.
On second thought, the change is trivial, so I committed it to RC. But it would be nice to have a test nevertheless so we can watch for regressions.
Done: unfortunately I had to split test_boost up into separate individual tests to be able to reliably detect these issues, so we've just acquired a whole bunch of new tests :-( On the other hand I did detect a missing #include from one of my headers in the process, so the tests should be more robust now. At the risk of stretching the release process I've added these new tests to the release branch as well: it's going to cause a small amount of churn while the test runs catch up, but it will enable us to detect genuine problems with this release now. John.

Peter Dimov wrote:
Not sure what we can do about this but:
#include <boost/shared_array.hpp>
doesn't compile when Boost.TR1 is added to the include path.
The above compiles for me.
I started migrating our projects over to Boost TR1 this weekend. First pass was array, shared_ptr and regex. Generally everything went fine, although I kept hitting problems with shared_array unless I #include <memory> before it - some problems with detail::shared_count. Otherwise very happy with the results. Around 100 projects and 1000 files updated, compiled and run pretty much straight out the box. [Using Borland 2006 and MSVC8] Will be taking a stab at bind next weekend, along with reference_wrapper, mem_fn - so hoping any circular header dependencies in <functional> are sorted soon <g> Probably won't try migrating function as we are predominantly using Borland compiler still - so no TR1 feedback here. Likewise, our main use of tuple is for tie-ing pairs, which is the failing test case for Borland compiler :?( -- AlisdairM
participants (3)
-
AlisdairM
-
John Maddock
-
Peter Dimov