public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98646] New: A static_cast confuses -Wnonnull, causing false positives
@ 2021-01-12 22:34 ville.voutilainen at gmail dot com
  2021-01-13  0:43 ` [Bug c++/98646] [11 Regression] " msebor at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: ville.voutilainen at gmail dot com @ 2021-01-12 22:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98646

            Bug ID: 98646
           Summary: A static_cast confuses -Wnonnull, causing false
                    positives
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com
  Target Milestone: ---

Created attachment 49957
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49957&action=edit
Preprocessed source

Compile with

/usr/local/bin/c++ -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT
-DQT_BUILD_XCB_PLUGIN -DQT_BUILD_XCB_QPA_LIB_LIB -DQT_CORE_LIB
-DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000
-DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_GUI_LIB -DQT_MOC_COMPAT
-DQT_NO_CAST_TO_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_OPENGL_LIB
-DQT_USE_QSTRINGBUILDER -DXcbQpa_EXPORTS -D_LARGEFILE64_SOURCE
-D_LARGEFILE_SOURCE -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall
-Wextra -fno-exceptions -fPIC -Werror -Wno-error=cpp
-Wno-error=deprecated-declarations -Wno-error=strict-overflow
-Wno-error=implicit-fallthrough -Wno-error=deprecated-copy
-Wno-error=redundant-move -Wno-error=init-list-lifetime
-Wno-error=format-overflow -Wsuggest-override -std=c++17 -c winid-nonnull.cpp

The result is
/home/vivoutil/kuutti/kuuttikutonen/qt5/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp:
In member function ‘void QXcbWindow::show()’:
/home/vivoutil/kuutti/kuuttikutonen/qt5/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp:685:91:
error: ‘this’ pointer null [-Werror=nonnull]
  685 |                 transientXcbParent = static_cast<const QXcbWindow
*>(tp->handle())->winId();
      |                                                                        
                  ^
In file included from
/home/vivoutil/kuutti/kuuttikutonen/qt5/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp:40:
/home/vivoutil/kuutti/kuuttikutonen/qt5/qtbase/src/plugins/platforms/xcb/qxcbwindow.h:87:9:
note: in a call to non-static member function ‘virtual WId QXcbWindow::winId()
const’
   87 |     WId winId() const override;
      |         ^~~~~

Removing the static_cast removes the warning.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-01-25 19:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 22:34 [Bug c++/98646] New: A static_cast confuses -Wnonnull, causing false positives ville.voutilainen at gmail dot com
2021-01-13  0:43 ` [Bug c++/98646] [11 Regression] " msebor at gcc dot gnu.org
2021-01-13  8:12 ` rguenth at gcc dot gnu.org
2021-01-14  2:42 ` mpolacek at gcc dot gnu.org
2021-01-14  2:43 ` mpolacek at gcc dot gnu.org
2021-01-14  3:11 ` mpolacek at gcc dot gnu.org
2021-01-14  3:23 ` mpolacek at gcc dot gnu.org
2021-01-14 11:21 ` rguenth at gcc dot gnu.org
2021-01-14 16:19 ` mpolacek at gcc dot gnu.org
2021-01-14 16:22 ` mpolacek at gcc dot gnu.org
2021-01-15  0:45 ` jakub at gcc dot gnu.org
2021-01-17  0:36 ` msebor at gcc dot gnu.org
2021-01-18 19:13 ` jakub at gcc dot gnu.org
2021-01-20  1:26 ` msebor at gcc dot gnu.org
2021-01-20 21:20 ` msebor at gcc dot gnu.org
2021-01-20 22:13 ` msebor at gcc dot gnu.org
2021-01-21  0:32 ` msebor at gcc dot gnu.org
2021-01-25 19:43 ` cvs-commit at gcc dot gnu.org
2021-01-25 19:44 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).