I think there is another solution: the rule of thumb for C++
programmers it to avoid overloading of template functions because
rules for choosing between two template candidates are extremely
complicated.

Instead programmers are encouraged to rely on partial template
specialization which is available for classes/structs. So we can
probably introduce auxiliary structure and rewrite the code in this
way (it's just a blueprint):

template<typename Dest, typename Source>
class BitCastHelper {
 public:
  static Dest cast(const Source& src) { // generic bit cast };
};

template<typename Dest, typename Source>
class BitCastHelper<Dest, Source*> {
 public:
  static Dest cast(const Source*& src) { // specialization for pointers };
};

template<typename Dest, typename Source>
Dest BitCast(const Source& src) { return BitCastHelper<Dest,
Source>::cast(src); }

--
Vyacheslav Egorov


On Thu, Sep 2, 2010 at 8:57 AM, Søren Gjesse <[email protected]> wrote:
>
> Hi
> This is a rather delicate matter and an area where we have been fighting with 
> GCC and especially strict aliasing with GCC 4.4. You can follow it in issue 
> 463. In r5237 we finally got a solution which fixed the GCC 4.4 problem. This 
> however caused problems with older GCCs which where addressed in r5305. 
> However this last change seems to be the one which breaks compiling with 
> RVCT. I just tried to re-introduce the & without the const, but that brings 
> back the strict aliasing issue with GCC 4.4 (4.4.3).
> Maybe the best solution here will be a conditional compile. Is there any 
> predefined macros which can uniquily identify RVCT?
> Regards,
> Søren
>
> On Wed, Sep 1, 2010 at 19:04, vlad <[email protected]> wrote:
>>
>> Hi,
>> Changing "Source* const & source" to just "Source* source" breaks rvct
>> build... However Source*& source works fine.
>>
>>   "v8.be\src\factory.h", line 335: Error:  #308: more than one
>> instance of overloaded function "v8::internal::BitCast" matches the ar
>> gument list:
>>               function template
>> "v8::internal::BitCast<Dest,Source>(const Source &)__softfp"
>>               function template
>> "v8::internal::BitCast<Dest,Source>(Source *)__softfp"
>>               argument types are: (v8::internal::Object **)
>>       ROOT_LIST(ROOT_ACCESSOR)
>>
>> template <class Dest, class Source>
>> inline Dest BitCast(Source* source) {
>>  return BitCast<Dest>(reinterpret_cast<uintptr_t>(source));
>> }
>>
>> Thanks
>> Vlad
>>
>> --
>> v8-dev mailing list
>> [email protected]
>> http://groups.google.com/group/v8-dev
>
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to