Creating a static xpressive regex object referencing statically
another regex object causes a spurious (and often extremely long)
warning when gcc's -W and -Wall flags are in use.
GCC version: version 4.1.3 20070831 (prerelease) (Ubuntu 4.1.2-16ubuntu1)
boost version: 1.34.0 and 1.34.1
To demonstrate this bug, build the following on -W -Wall:
--- boostbug.cc ---
#include
int main() {
boost::xpressive::sregex r1 = boost::xpressive::digit;
boost::xpressive::sregex r2 = *r1;
return 0;
}
--- end boostbug.cc ---
The warning output is as follows:
/usr/include/boost/xpressive/detail/utility/tracking_ptr.hpp: In copy
constructor 'boost::xpressive::detail::enable_reference_tracking<Derived>::enable_reference_tracking(const
boost::xpressive::detail::enable_reference_tracking<Derived>&) [with
Derived = boost::xpressive::detail::regex_impl<__gnu_cxx::__normal_iterator > >]':
/usr/include/boost/xpressive/detail/core/regex_impl.hpp:63:
instantiated from
'boost::xpressive::detail::regex_impl<BidiIter>::regex_impl(const
boost::xpressive::detail::regex_impl<BidiIter>&) [with BidiIter =
__gnu_cxx::__normal_iterator >]'
/usr/include/boost/xpressive/detail/utility/tracking_ptr.hpp:173:
instantiated from 'void
boost::xpressive::detail::enable_reference_tracking<Derived>::tracking_clear()
[with Derived =
boost::xpressive::detail::regex_impl<__gnu_cxx::__normal_iterator > >]'
/usr/include/boost/xpressive/detail/utility/tracking_ptr.hpp:395:
instantiated from 'boost::xpressive::detail::tracking_ptr<Type>&
boost::xpressive::detail::tracking_ptr<Type>::operator=(const
boost::xpressive::detail::tracking_ptr<Type>&) [with Type =
boost::xpressive::detail::regex_impl<__gnu_cxx::__normal_iterator > >]'
/usr/include/boost/xpressive/detail/utility/tracking_ptr.hpp:373:
instantiated from
'boost::xpressive::detail::tracking_ptr<Type>::tracking_ptr(const
boost::xpressive::detail::tracking_ptr<Type>&) [with Type =
boost::xpressive::detail::regex_impl<__gnu_cxx::__normal_iterator > >]'
/usr/include/boost/xpressive/basic_regex.hpp:53: instantiated from
'boost::xpressive::basic_regex<BidiIter>::basic_regex(const
boost::xpressive::basic_regex<BidiIter>&) [with BidiIter =
__gnu_cxx::__normal_iterator >]'
boostbug.cc:4: instantiated from here
/usr/include/boost/xpressive/detail/utility/tracking_ptr.hpp:205:
warning: base class 'class
boost::enable_shared_from_this > > >' should be explicitly initialized in the
copy constructor
I've attached a trivial patch (against 1.34.0; applies cleanly to
1.34.1) to silence this warning.