> On Aug 4, 2021, at 9:23 AM, Arrigo Marchiori <ard...@yahoo.it.INVALID> wrote:
> 
> Hello Jim,
> 
> On Wed, Aug 04, 2021 at 08:09:11AM -0400, Jim Jagielski wrote:
> 
>>> On Aug 4, 2021, at 7:54 AM, Arrigo Marchiori <ard...@yahoo.it.INVALID> 
>>> wrote:
>>> 
>>> Hello Jim,
>>> 
>>> On Wed, Aug 04, 2021 at 07:39:14AM -0400, Jim Jagielski wrote:
>>> 
>>>> Can you apply the below to your catalina branch build and see how it works?
>>>> 
>>>> diff --git a/main/comphelper/inc/comphelper/extract.hxx 
>>>> b/main/comphelper/inc/comphelper/extract.hxx
>>>> index dc67c5dc58..97c4d080f4 100644
>>>> --- a/main/comphelper/inc/comphelper/extract.hxx
>>>> +++ b/main/comphelper/inc/comphelper/extract.hxx
>>>> @@ -131,16 +131,22 @@ inline sal_Bool SAL_CALL extractInterface(
>>>> inline sal_Bool SAL_CALL any2bool( const ::com::sun::star::uno::Any & rAny 
>>>> )
>>>>    throw( ::com::sun::star::lang::IllegalArgumentException )
>>>> {
>>>> -  if (rAny.getValueTypeClass() == 
>>>> ::com::sun::star::uno::TypeClass_BOOLEAN)
>>>> +  bool bValue;
>>>> +  sal_Bool sBValue;
>>>> +  if ( rAny >>= bValue )
>>>>    {
>>>> -          return *(sal_Bool *)rAny.getValue();
>>>> +          return *(sal_Bool *)bValue;     // Why not just 
>>>> (sal_Bool)bValue ?
>>> 
>>> Are you sure about returning "*(sal_Bool *)bValue"? Are we not
>>> treating bValue as a pointer here, while it is a bool?
>>> To me it looks like returning either *0 or *1...
>>> 
>> 
>> Well, 2 things:
>> 
>>  1. As you can see, the format is the exact that we've had all along
>>  2. We cast as a pointer to a sal_Bool and then get the contents of the 
>> pointer (ie: re return the deref of the pointer, not the pointer
> 
> Yes, but in your patch we are substituting a call to rAny.getValue(),
> that returns `const void *` with `bValue` that is `bool`.
> http://opengrok.openoffice.org/xref/aoo41x/main/cppu/inc/com/sun/star/uno/Any.h?r=24f6443d#163
>  
> <http://opengrok.openoffice.org/xref/aoo41x/main/cppu/inc/com/sun/star/uno/Any.h?r=24f6443d#163>
> 
> For this reason IMHO the cast makes sense the first time and not the
> second...
> 
> I'd rather do:
> 
>  return *(sal_Bool *)&bValue;
>                      ^
>> Why we do that (cast as a pointer and then deref) is curious, hence the 
>> comment
> 
> I totally agree on this. It looks like type punning.
> 

IMO, we should just return (sal_Bool) bValue

Reply via email to