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


On 09/10/2015 12:11 PM, Eike Rathke wrote:
On Wednesday, 2015-09-09 07:17:47 +0000, stephan.bergmann.tinderbox@googlemail.com wrote:

/home/tinderbox/master/sc/qa/unit/ucalc_formula.cxx:5599:41: error: elide construction of 
rtl::OUString with string constant argument in call of rtl::operator+ [loplugin:stringconstant]
         CPPUNIT_ASSERT_EQUAL( aPrefix + OUString("448"), aPrefix + m_pDoc->GetString( aPos));

That's funny, because I tried without the ctor first and it didn't
compile.. I guess the cppunit type deduction gets in the way there.

Yeah, that one is somewhat funny (aPrefix and m_pDoc->GetString(aPos) both being of type OUString, too):

* OUString + OUString returns a OUStringConcat<OUString, OUString> (at least in LIBO_INTERNAL_ONLY)

*  OUString + "literal" returns some OUStringConcat<OUString, char const[N]>

* CPPUNIT_ASSERT_EQUAL(a, b), somewhat unfortunately, requires a and b to be of the same type (and ultimately calls "a == b")

So CPPUNIT_ASSERT_EQUAL(OUString+OUString, OUString+OUString) happens to compile (and does the right thing, as OUString+OUString == OUString+OUString will use the implicit OUString(OUStringConcat) conversion ctor to end up as OUString == OUString).

But CPPUNIT_ASSERT_EQUAL(OUString+"literal", OUString+OUString) fails to compile due to two different types being passed to CPPUNIT_ASSERT_EQUAL.

(What fixes it and still works around the---somewhat unhelpful in this specific case, but often useful---loplugin::stringconstant warning, is <http://cgit.freedesktop.org/libreoffice/core/commit/?id=e4757b79e2938e48a57d129413df3f06bf638b4d> "WaE: loplugin:stringconstant.")

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.