Build warnings on Linux (strict-overflow in sc + unused variable in vcl)

Stephan Bergmann sbergman at redhat.com
Wed May 11 07:15:43 UTC 2016


On 05/10/2016 09:36 PM, julien2412 wrote:
> On pc Debianx86-64 with master sources, I've got this error:
> /home/julien/lo/libreoffice/sc/source/core/data/markmulti.cxx: In member
> function ‘void ScMultiSel::SetMarkArea(SCCOL, SCCOL, SCROW, SCROW, bool)’:
> /home/julien/lo/libreoffice/sc/source/core/data/markmulti.cxx:242:50: error:
> assuming signed overflow does not occur when assuming that (X + c) >= X is
> always true [-Werror=strict-overflow]
>              while ( nBeg != MAXROWCOUNT && nLast < nEndRow )
>
> ^
> cc1plus: all warnings being treated as errors
>
> Searching on Opengrok, here are their type:
> SCROW nBeg, nLast = nEndRow + 1; (see
> http://opengrok.libreoffice.org/xref/core/sc/source/core/data/markmulti.cxx#225)
> void ScMultiSel::SetMarkArea( SCCOL nStartCol, SCCOL nEndCol, SCROW
> nStartRow, SCROW nEndRow, bool bMark ) (line 206 of same file)

This is a very dreaded warning from the GCC compiler.  It appears to 
often be emitted at stages late in the compilation pipeline, when the 
internal code representation that triggers the warning no longer maps to 
the original source code in a comprehensible way.  It also appears to be 
emitted more often when compiling with higher optimization levels.  (For 
example, it appears to be emitted after aggressively inlining code, or 
after instantiating a specific template specialization.)  Also, it 
appears that different versions of GCC suffer from different ways in 
which this warning gets emitted in presumably bogus ways.

For an example of how one---known bogus---incarnation of that problem 
had been addressed see 
<https://cgit.freedesktop.org/libreoffice/core/commit/?id=897c8af7948aae8f3e3014f9f23846ef1ca5c6cd> 
"Silence bogus GCC 4.9 -Werror=strict-overflow".

> Other warning I got is:
> /home/julien/lo/libreoffice/vcl/unx/gtk/gtksalmenu.cxx: In function
> ‘MenuAndId {anonymous}::decode_command(const gchar*)’:
> /home/julien/lo/libreoffice/vcl/unx/gtk/gtksalmenu.cxx:892:17: error: unused
> variable ‘sWindow’ [-Werror=unused-variable]
>          OString sWindow = sCommand.getToken(0, '-', nIndex);
>                         ^
> Indeed sWindow is only used in line 898:
> assert(sWindow == "window" && pSalSubMenu);

Yes, that's a commonly experienced problem with assert, where its 
argument gets completely ignored under NDEBUG.  One way to avoid the 
warning is to cast sWindow to void.


More information about the LibreOffice mailing list