flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:

Home Page:https://flameshot.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fails with strict-aliasing violations

eli-schwartz opened this issue · comments

I tried to compile with LTO: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

The -Werror=* flags are important to detect cases where the compiler can try to optimize based on assuming UB cannot happen, and miscompile code that has UB in it. strict-aliasing issues are always bad but LTO can make them even worse.

I got this error:

FAILED: src/CMakeFiles/flameshot.dir/core/capturerequest.cpp.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -DAPP_PREFIX=\"/usr\" -DAPP_VERSION=\"v12.1.0\" -DFLAMESHOT_APP_VERSION_URL=\"https://api.github.com/repos/flameshot-org/flameshot/releases/latest\" -DFLAMESHOT_GIT_HASH=\"\" -DPREDEFINED_COLOR_PALETTE_LARGE=false -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_SVG_LIB -DQT_WIDGETS_LIB -DUSE_EXTERNAL_SINGLEAPPLICATION=1 -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0_build/src/flameshot_autogen/include -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/.. -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/../external/Qt-Color-Widgets/include -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/../dbus -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/cli -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/config -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/core -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/arrow -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/pixelate -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/circle -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/circlecount -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/copy -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/exit -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/imgur -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/launcher -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/line -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/marker -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/move -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/pencil -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/pin -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/rectangle -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/redo -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/save -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/invert -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/selection -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/sizeindicator -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/text -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/undo -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/sizeincrease -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/tools/sizedecrease -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/utils -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/widgets -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/widgets/panel -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/widgets/capture -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0_build -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/external/Qt-Color-Widgets/include -I/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0_build/external/Qt-Color-Widgets -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtSvg -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/mkspecs/linux-g++ -isystem /usr/include/qt5/QtDBus -isystem /usr/include/qt5/QtNetwork  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -fPIC -MD -MT src/CMakeFiles/flameshot.dir/core/capturerequest.cpp.o -MF src/CMakeFiles/flameshot.dir/core/capturerequest.cpp.o.d -o src/CMakeFiles/flameshot.dir/core/capturerequest.cpp.o -c /var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/core/capturerequest.cpp
/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/core/capturerequest.cpp: In member function ‘void CaptureRequest::removeTask(ExportTask)’:
/var/tmp/portage/media-gfx/flameshot-12.1.0-r2/work/flameshot-12.1.0/src/core/capturerequest.cpp:72:12: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
   72 |     ((int&)m_tasks) &= ~task;
      |            ^~~~~~~
cc1plus: some warnings being treated as errors
ninja: build stopped: subcommand failed.

Downstream report: https://bugs.gentoo.org/859613
Full build log: build.log