[Libreoffice] warnig and coding, need a little help on C++

Caolán McNamara caolanm at redhat.com
Thu Nov 25 12:57:59 PST 2010


On Thu, 2010-11-25 at 19:41 +0100, Pierre-André Jacquod wrote:
> {
>      sal_Int8 nTemp;
>      rVal >>= nTemp;
>      if(nTemp >=1 && nTemp < 0x7f
>      nLines = (BYTE)nTemp;
> }
> 
> Well, that's fine for me, nTemp is effectively not initialized. And the
> second line is then the same as: rVal = rVal >> nTemp
> 
> In my understanding, since nTemps is not initialized, if the compiler is
> nice, nTemp is then defaulted to 0 (or NULL). Then rVal = rVal >> 0 make
> not a lot of sense

> OK, now the question: what did I missed ?????

Heh, this also confuses cppcheck as well. rVal is an "Any" and there is
an overloaded "operator >>=" which operates on that "Any" and nTemp. So
its not anything to do with bit shifting. Read it like...

rVal.ExtractTo(nTemp)

Now, if >>= fails it leaves nTemp untouched. So the general fix is
indeed to initialize nTemp to 0 to clear the warning.

C.



More information about the LibreOffice mailing list