Boost logo

Boost :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-02-21 20:03:36


This mail is about regex library test concept_check on Tru64/cxx and
HP-UX/aCC6.

First Tru64. For Tru64/cxx -- both "tru64cxx*" and "hp_cxx*" toolsets --
this test is marked expected failure with the following remark:

  [ Markus Schoepflin ] The failure is caused by a compiler bug, which
  has been reported to the compiler supplier (or is already known to them).

I don't recall a problem report associated with this test and could not
locate it in our bug tracking system. It does not mean that the report has
not been submitted, of course. I'll need to look more.

Anyway, the test fails to compile on Tru64/cxx with the following error:

  class "std::char_traits<boost::char_architype>" has no member "char_type"
  (notmember)
  detected during:
    instantiation of class "std::basic_string<charT, traits, Allocator>
      [with charT=boost::char_architype,
      traits=std::char_traits<boost::char_architype>,
      Allocator=std::allocator<
      boost::regex_traits_architype<boost::char_architype>::char_type>]"

boost/regex/concepts.hpp provides explicit specialization of class
std::char_traits for boost::char_architype, as the following:

//
// char_architype can not be used with basic_string:
//
} // namespace boost
namespace std{
   template<> struct char_traits<boost::char_architype>{};
}

This (empty) specialization does not provide typedefs listed in 21.1.2 -
traits typedefs [lib.char.traits.typedefs], in particular char_type which
is the type Rogue Wave library version 2.0 expects.

Adding char_type to the specialization makes the test compile:

#if defined(__DECCXX) && BOOST_WORKAROUND(_RWSTD_VER, == 0x0203)
   template<> struct char_traits<boost::char_architype> {
     typedef boost::char_architype char_type;
   };
#else
   template<> struct char_traits<boost::char_architype>{};
#endif

If this workaround makes sense, perhaps, it is not too late to apply it
to 1.34 (Tru64/cxx is a release platform).

Now HP-UX/aCC6. On this platform, test concept_check also does not compile,
but because of the different version of RW library, the first compilation
error is:

  no instance of overloaded function "std::__iterator_category" matches the
  argument list
    argument types are:
      (boost::bidirectional_iterator_archetype<
       boost::BoostRegexConcept<boost::basic_regex<char,
                                boost::c_regex_traits<char>>>::value_type>)
   if (__is_bidirectional_iterator(__iterator_category(first2)))
                                   ^
Here is reduced reproducer:

---%<---
#include <boost/regex/concepts.hpp>
void f() {
  boost::bidirectional_iterator_archetype<
    boost::BoostRegexConcept<
      boost::basic_regex<char, boost::c_regex_traits<char>
>
>::value_type> x;
  std::string(x, x);
}
--->%---

Reproducer above compiles cleanly with RW 2.0 (the version on Tru64),
STLport, and Gnu libstdc++. It does not compile with RW 2.2 (the version
of RW library on HP-UX) because this version of RW library has a function
that checks iterator type and expects its argument to be either a pointer
or a class template with the standard signature for an iterator. Here is
the function:

inline random_access_iterator_tag __iterator_category (const _TypeT*)
{
    return random_access_iterator_tag ();
}

template <class _Category, class _TypeT, class _Distance,
          class _Pointer, class _Reference>
inline _Category
__iterator_category (const iterator<_Category, _TypeT,
                                    _Distance, _Pointer, _Reference>&)
{

    typedef typename iterator<_Category, _TypeT, _Distance, _TypeT*,
                               _TypeT&>::iterator_category _IterCategory;

    return _IterCategory ();
}

The __iterator_category function is used in basic_string::replace()
function for the optimization:

template<class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
inline basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::
replace (iterator first1, iterator last1,
         _InputIterator first2, _InputIterator last2,
         _RWSTD_DISPATCH_INT (false))
{
...
     // Use a (probably)faster algorithm if possible
     if (__is_bidirectional_iterator(__iterator_category(first2)))
       return __replace_aux(first1, last1, first2, last2);
...

The following workaround in boost/concept_archetype.hpp eliminates
compilation error:

#if defined(__HP_aCC) && BOOST_WORKAROUND(_RWSTD_VER, == 0x02020100)
namespace std {
struct __unknown_iterator_tag {};
template <class _TypeT>
inline __unknown_iterator_tag __iterator_category (const _TypeT)
{
    return __unknown_iterator_tag ();
}
} // namespace std
#endif

Since HP-UX/aCC6 is not a release platform, I'm not asking to apply this
workaround to 1.34. If workaround makes sense, it can be applied to HEAD.

There are other compilation errors on HP-UX/aCC6 which I'm planning to
investigate in the next couple of days. In the meantime, I'd appreciate
it if regex library test concept_check was marked expected failure on
HP-UX/aCC6 (toolset "acc"), in both 1.34 and HEAD. Hopefully, we'll be
able to "unmark" it in HEAD.

Thanks,
  Boris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk