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

On Thursday 05 of April 2012, 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)

warning: comparison with string literal results in unspecified behaviour 

 That could be promoted to errors by default if wanted.

 The only case I can think of that won't warn is comparing const char* 
pointers. That is unlikely to be a direct result of RTL_CONSTASCII changes, 
although possibly somebody could be lured by the OUString convenience into 
doing that elsewhere. Although, on the other hand, this is a rather unlikely 
case with C++, such person would hopefully simply go for OUString anyway, and 
it'd also require that person to actually not test the code. So hopefully 
very unlikely and IMO not worth the inconvenience.

 There'd be also the possibility of getting a warning about comparing const 
char* pointers into the compilers, but I wonder how many false positives that 
would give.

 Lubos Lunak
 l.lunak at suse.cz

More information about the LibreOffice mailing list