Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


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 
[-Waddress]

 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@suse.cz

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.