using bool in rtl::OUStringBuffer::append

Stephan Bergmann sbergman at redhat.com
Thu Oct 4 01:21:49 PDT 2012


On 10/04/2012 07:49 AM, Noel Grandin wrote:
> On 2012-10-03 22:03, Stephan Bergmann wrote:
>>> places. The commit seems to have caused some test failures and
>>> crashes. I reverted it for now.
>>
>> ...which only goes to show what a horrible mess C++ is in practice.
>> bool is rather special, but you easily forget to consider all the
>> consequences of that.  Turns out that code like
>>   aBuf.append( pElementType->pTypeName );
>> (typelib_static_sequence_type_init,
>> cppu/source/typelib/static_types.cxx), where pElementType->pTypeName
>> is of type rtl_uString*, now chooses for overload resolution the
>> standard boolean conversion from rtl_uString* to bool (yielding true,
>> so appending "true" to aBuf) rather than the user-defined conversion
>> by constructor from rtl_uString* to rtl::OUString.
>
> Can that be fixed by adding an
>     OUStringBuffer::append( rtl_uString* )
> method, which does the necessary conversion internally?

That would solve this specific incident, but who knows what other, 
similar problems with other types would still be lurking.

Stephan



More information about the LibreOffice mailing list