Menu

#786 Overwhelming number of "optimization attribute" warnings

v1.0 (example)
closed-invalid
nobody
None
5
2019-02-13
2019-02-09
Peepsalot
No

I'm seeing many thousands of seemingly nonsense warnings when building a project using x86_64-w64-mingw32.static.posix-g++ version 7.3.0 which is built from MXE.
I also tried building gcc 8.2 and see the same sort of things.

It seems they all are "optimization attribute" warnings on operator declarations, and this build of gcc can't differentiate between these operator signatures which take very different types in their arguments

Here is one example out of 56627 warnings from this build:

In file included from ../src/Camera.h:19:0,
                 from ../src/GLView.h:25,
                 from ../src/QGLView.h:15,
                 from objects/ui_MainWindow.h:34,
                 from ../src/MainWindow.h:6,
                 from ../src/input/InputDriverManager.h:34,
                 from ../src/LibraryInfo.cc:6:
../src/linalg.h:32:67: warning: optimization attribute on 'BoundingBox operator*(const Affine3d&, const BoundingBox&)' follows definition but the attribute doesn't match [-Wattributes]
 BoundingBox operator*(const Transform3d &m, const BoundingBox &box);
                                                                   ^
In file included from /mxe/usr/x86_64-w64-mingw32.static.posix/qt5/include/QtGui/qevent.h:56:0,
                 from /mxe/usr/x86_64-w64-mingw32.static.posix/qt5/include/QtGui/qtextlayout.h:49,
                 from /mxe/usr/x86_64-w64-mingw32.static.posix/qt5/include/QtGui/qabstracttextdocumentlayout.h:45,
                 from /mxe/usr/x86_64-w64-mingw32.static.posix/qt5/include/QtWidgets/qplaintextedit.h:51,
                 from /mxe/usr/x86_64-w64-mingw32.static.posix/qt5/include/QtWidgets/QPlainTextEdit:1,
                 from ../src/Console.h:29,
                 from objects/ui_MainWindow.h:32,
                 from ../src/MainWindow.h:6,
                 from ../src/input/InputDriverManager.h:34,
                 from ../src/LibraryInfo.cc:6:
/mxe/usr/x86_64-w64-mingw32.static.posix/qt5/include/QtGui/qvector2d.h:241:41: note: previous definition of 'constexpr const QVector2D operator*(const QVector2D&, const QVector2D&)' was here
 Q_DECL_CONSTEXPR inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
                                         ^~~~~~~~

This would be a compiler bug, right?

Discussion

  • Peepsalot

    Peepsalot - 2019-02-10

    OK, I've narrowed down the issue to a simple test case, and found that it has to do with including Eigen/Core between different operator declarations.

    In the actual project this is due to various nested includes, some using Eigen, some not.

    test.cc

    class A {
    private:
      friend int &operator<<(int &i, const A &value) { return i; }
    };
    
    #include <Eigen/Core>
    
    class B {};
    
    int &operator<<(int &i, const B &ast);
    

    my compile command is
    x86_64-w64-mingw32.static.posix-g++ -c -isystem /mxe/usr/x86_64-w64-mingw32.static.posix/include/eigen3 test.cc

    and the result looks like:

    test.cc:10:37: warning: optimization attribute on 'int& operator<<(int&, const B&)' follows definition but the attribute doesn't match [-Wattributes]
     int &operator<<(int &i, const B &ast);
                                         ^
    test.cc:3:15: note: previous definition of 'int& operator<<(int&, const A&)' was here
       friend int &operator<<(int &i, const A &value) { return i; }
                   ^~~~~~~~
    

    I've seen these sort of warnings coming from two different CI servers, one using MXE, and the other using msys2.
    on MXE it builds: eigen-3.2.5
    on msys2 it installs package: mingw-w64-x86_64-eigen3-3.3.5-1

    The native linux / mac os builds do not do this so it seems something that is common only to mingw builds.

     

    Last edit: Peepsalot 2019-02-10
  • LIU Hao

    LIU Hao - 2019-02-12

    This is probably a GCC issue, so please report it to https://gcc.gnu.org/bugzilla/.

     
  • Peepsalot

    Peepsalot - 2019-02-13

    OK, I was able to minimize the test case (following instructions from gcc) down to a single line from Eigen that causes the problem, and filed a bug report here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325

     
  • LIU Hao

    LIU Hao - 2019-02-13
    • status: open --> closed-invalid
     
  • LIU Hao

    LIU Hao - 2019-02-13

    Nice. Looks like someone has been working on it. Closing this for now.

     

Log in to post a comment.

MongoDB Logo MongoDB