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@suse.cz
Context
- Re: RTL_CONSTASCII_(U)STRINGPARAM officially obsolete (continued)
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.