Cppcheck false positive? (eg 'PropEntry::operator=' should return 'PropEntry &')

Julien Nabet serval2412 at yahoo.fr
Thu Dec 27 11:42:55 PST 2012

On 27/12/2012 19:36, Kohei Yoshida wrote:
> On Thu, Dec 27, 2012 at 9:53 AM, julien2412 <serval2412 at yahoo.fr 
> <mailto:serval2412 at yahoo.fr>> wrote:
>     Hello,
>     Cppcheck reports this kind of thing:
>     [sd/source/filter/ppt/propread.hxx:116]: (style)
>     'PropEntry::operator='
>     should return 'PropEntry &'.
>         116     const PropEntry& operator=(const PropEntry& rPropEntry);
>     Indeed, I understand this cppcheck report, if you assign a
>     variable, the
>     result can't be considered as "const".
> Yes, the assignment operator should always return a non-const 
> reference of self.  Cppcheck is correct on this.
> Kohei
Thank you Kohei for your feedback, I pushed 2 commits, see:


But there are still these:
[lingucomponent/source/languageguessing/simpleguesser.hxx:43]: (style) 
'SimpleGuesser::operator=' should return 'SimpleGuesser &'.
[reportdesign/source/filter/xml/xmlComponent.hxx:37]: (style) 
'OXMLComponent::operator=' should return 'OXMLComponent &'.
[reportdesign/source/filter/xml/xmlFunction.hxx:41]: (style) 
'OXMLFunction::operator=' should return 'OXMLFunction &'.
[reportdesign/source/filter/xml/xmlGroup.hxx:38]: (style) 
'OXMLGroup::operator=' should return 'OXMLGroup &'.
[reportdesign/source/filter/xml/xmlCell.hxx:41]: (style) 
'OXMLCell::operator=' should return 'OXMLCell &'.

All except first one, return an object instead of a ref to an object. I 
don't know if I can't just put "&" or if it should be investigated.
First one isn't an assignment but a comparison! Isn't it a little dangerous?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20121227/e6036eb6/attachment.html>

More information about the LibreOffice mailing list