RTL_CONSTASCII_(U)STRINGPARAM officially obsolete

Lubos Lunak l.lunak at suse.cz
Thu Apr 5 06:09:43 PDT 2012


On Thursday 05 of April 2012, Noel Grandin wrote:
> On 2012-04-05 14:47, Caolán McNamara wrote:
> > Cause I worry that someone's going to end up comparing string literals
> > to each other under some conversion like
> >
> > -#define FOO rtl::OUString(..."foo"...)
> > +#define FOO "foo"
> > -#define BAR rtl::OUString(..."bar"...)
> > +#define BAR "bar"
> >
> > if (FOO == BAR)
>
> You could solve that with some tainting.
> So you have a boolean flag inside an OUString that says "I was created
> from a literal".
> Then you check in the equality operator if the other side also has the
> flag, and if so, complain loudly.

 if( "foo" == "foo" ) does not involve OUString at all, it is a mere pointer 
comparsion, and in this specific case it is undefined if the comparison 
evaluates to true or false (depends on string literal duplicates merging). 
Which is why this would be a problem, but compilers warn about this.

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list