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

classic Classic list List threaded Threaded
6 messages Options
julien2412 julien2412
Reply | Threaded
Open this post in threaded view
|

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

Hello,

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)

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);

Of course, I could remove --enable-werror but would like to know how to fix these warnings properly.

Any thoughts?

Julien
julien2412 julien2412
Reply | Threaded
Open this post in threaded view
|

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

About strict-overflow error, I submitted https://gerrit.libreoffice.org/#/c/24863/
julien2412 julien2412
Reply | Threaded
Open this post in threaded view
|

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

With the patch already quoted applied locally + "(void) sWindow;" for vcl parl, I kept on the build.

Now I've got something a bit weird (this time in sw module) ::
/home/julien/lo/libreoffice/sw/source/core/text/txtfrm.cxx: In member function ‘virtual bool SwTextFrame::Prepare(PrepareHint, const void*, bool)’:
/home/julien/lo/libreoffice/sw/source/core/text/txtfrm.cxx:1447:6: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
 bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid,
          ^
How a function may trigger this?
sberg sberg
Reply | Threaded
Open this post in threaded view
|

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

In reply to this post by julien2412
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.
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Eike Rathke-2 Eike Rathke-2
Reply | Threaded
Open this post in threaded view
|

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

In reply to this post by julien2412
Hi julien2412,

On Tuesday, 2016-05-10 13:54:54 -0700, julien2412 wrote:

> About strict-overflow error, I submitted
> https://gerrit.libreoffice.org/#/c/24863/

Ok in this case, might be trickier in other cases.

  Eike

--
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GPG key "ID" 0x65632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Better use 64-bit 0x6A6CD5B765632D3A here is why: https://evil32.com/
Care about Free Software, support the FSFE https://fsfe.org/support/?erack

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (836 bytes) Download Attachment
julien2412 julien2412
Reply | Threaded
Open this post in threaded view
|

[SOLVED] Re: Build warnings on Linux (strict-overflow in sc + unused variable in vcl)

In reply to this post by julien2412
Thank you Stephan and Eike for your feedback! :-)

I submitted these for review:
https://gerrit.libreoffice.org/#/c/24899/ (-Werror=unused-variable for non debug build)
https://gerrit.libreoffice.org/#/c/24900/ (Silence bogus GCC 5.3 -Werror=strict-overflow)

Julien