[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-cxx-dev
Subject:    Re: CXX-DEV: why is this code rejected by aCC 6?
From:       "Boris Gubenko" <Boris.Gubenko () hp ! com>
Date:       2005-12-30 8:52:50
Message-ID: 004801c60d1e$6a447890$0200a8c0 () americas ! hpqcorp ! net
[Download RAW message or body]

>
> I'm trying to overload a function: one takes (type T1, type T2) the
> other
> takes (type T2, type T1) but the compiler seems to be rejecting this
> for
> some reason. (In my particular case, the types are a pair and an
> iterator.)
>

  No, in your example in <http://kinoko.c.u-tokyo.ac.jp/~duraid/
  /hpstuff/pair_vs_iterator_bug.i>, the types are a pair and a pair
  and '#2403: invalid redeclaration of member function' error is
  justified.

  In 'unsigned BytecodeReader::getTypeSlot(const Type *Ty)', you call
  lower_bound as the following:

std::vector<std::pair<const Type*, unsigned> > ModuleTypeIDCache;
  std::vector<std::pair<const Type*, unsigned> >::iterator IT =
    std::lower_bound(ModuleTypeIDCache.begin(), ModuleTypeIDCache.end(),
                     std::make_pair(Ty, 0U));

  Here is the code of lower_bound():

template <class _FwdIter, class _TypeT>
inline _FwdIter
lower_bound (_FwdIter __first, _FwdIter __last, const _TypeT &__val)
{
    return std::lower_bound (__first, __last, __val,
                             __rw::__rw_lt2<typename std::iterator_traits< 
_FwdIter > ::value_type, _TypeT>());
}

  Given the call from getTypeSlot() above, on what types
  __rw::__rw_lt2<T1,T2> will be instantiated?

  Consider x.cpp below which gives the same #2403 error.

x.cpp
-----
namespace __rw {
template <class _TypeT1, class _TypeT2>
struct __rw_lt2
{
    bool operator() (const _TypeT1 &__lhs, const _TypeT2 &__rhs) const;
    bool operator() (const _TypeT2 &__lhs, const _TypeT1 &__rhs) const;
};
}

namespace std {
template <class _TypeT, class _TypeU>
struct pair {};
}

class Ty;
__rw::__rw_lt2<std::pair<const Ty*, unsigned>,
               std::pair<const Ty*, unsigned> > x;

  Boris

----- Original Message ----- 
From: <duraid@octopus.com.au>
To: <cxx-dev@cxx.cup.hp.com>
Sent: Thursday, December 29, 2005 4:16 AM
Subject: CXX-DEV: why is this code rejected by aCC 6?


> Is aCC 6.06 being a bit too evil? Looking at the following error message:
> I'm trying to overload a function: one takes (type T1, type T2) the other
> takes (type T2, type T1) but the compiler seems to be rejecting this for
> some reason. (In my particular case, the types are a pair and an
> iterator.)
>
> "/home/duraid/stdcxx/include/rw/_algobase.h", line 147: error #2403: 
> invalid
>          redeclaration of member function "__rw::__rw_lt2<_TypeT1,
>          _TypeT2>::operator()(const _TypeT1 &, const _TypeT2 &) const 
> [with
> 
> _TypeT1=std::iterator_traits<__rw::__rw_debug_iter<std::vector<uint64
>          _t, std::allocator<uint64_t>>, std::vector<uint64_t,
>          std::allocator<uint64_t>>::const_pointer, std::vector<uint64_t,
>          std::allocator<uint64_t>>::pointer>>::value_type,
> _TypeT2=uint64_t]"
>          (declared at line 144)
>      bool operator() (const _TypeT2 &__lhs, const _TypeT1 &__rhs) const {
>           ^
>          detected during:
>            instantiation of class "__rw::__rw_lt2<_TypeT1, _TypeT2> [with
> 
> _TypeT1=std::iterator_traits<__rw::__rw_debug_iter<std::v
>                      ector<uint64_t, std::allocator<uint64_t>>,
>                      std::vector<uint64_t,
>                      std::allocator<uint64_t>>::const_pointer,
>                      std::vector<uint64_t,
>                      std::allocator<uint64_t>>::pointer>>::value_type,
>                      _TypeT2=uint64_t]" at line 981 of
>                      "/home/duraid/stdcxx/include/algorithm"
>
> You can reproduce this error by trying:
>
> aCC -AA -w -c pair_vs_iterator_bug.i
>
> (you can grab this file here:
>
> http://kinoko.c.u-tokyo.ac.jp/~duraid/hpstuff/pair_vs_iterator_bug.i )
>
>    Merry xmas one and all! Hope everyone is enjoying the season. :)
>
>    Duraid
> _________________________________________________________________
> To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
>    with the message UNSUBSCRIBE cxx-dev
> _________________________________________________________________
>
> 
 _________________________________________________________________
 To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
    with the message UNSUBSCRIBE cxx-dev
 _________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic