Open
Conversation
Signed-off-by: niranda perera <niranda.perera@gmail.com>
pciolkosz
approved these changes
Mar 4, 2026
Contributor
|
Thanks for looking into it, it seems someone with cmake ownership needs to approve as well |
This comment has been minimized.
This comment has been minimized.
miscco
requested changes
Mar 4, 2026
Comment on lines
+351
to
+353
| // GCC cannot prove __query_interface returns non-null for __iunknown (the invariant guarantees it) | ||
| _CCCL_DIAG_PUSH | ||
| _CCCL_DIAG_SUPPRESS_GCC("-Wnull-dereference") |
Contributor
There was a problem hiding this comment.
Critical: some compilers have issues with warning suppression inside of class definitions. We should rather move the suppression outside to a single one at the top and one push at the bottom.
Contributor
Author
There was a problem hiding this comment.
@miscco what's the better practice here? Should I move the PUSH to the very top of the cpp file covering all methods? Or just cover these 2 methods?
Because, in the future, if some other warning needs to be suppressed, we should be able to see the existing warning suppressions.
This comment has been minimized.
This comment has been minimized.
Contributor
🥳 CI Workflow Results🟩 Finished in 1h 31m: Pass: 100%/99 | Total: 1d 10h | Max: 1h 14m | Hits: 94%/255613See results here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7875
Enables
-Wnull-dereference(with-Werror) in the libcudacxx test suite and suppresses the resulting GCC false-positive warnings in the__basic_anytype-erasure implementation.Why
-Wnull-dereference?-Wnull-dereferenceasks GCC to perform inter-procedural null-pointer flow analysis and warn (with-Werror, hard-fail) on any code path that can reach a dereference through a pointer that could be null. This catches a class of bugs that-Walland-Wextramiss.Why the suppressions?
GCC's analysis cannot see through
__basic_any's type-erasure invariants. When__query_interfaceis inlined, GCC observes itsreturn nullptrbranch and concludes the result might be null at every call site, even those that are guarded by the design (e.g.,__iunknownis always registered, virtual dispatch is only reached through a live object). This leads to false-positive errors in three locations:virtcall.h__virtcall—__vptr->__fn_(...)__query_interfaceinlined; GCC sees potentialnullptrbasic_any_value.hreset()/type()—__query_interface(__iunknown())->...__iunknownlookup inlined, nullable path visiblertti.h__try_vptr_cast—rtti->__query_interface(...)__query_interface(__iunknown())inlined into slow-path castEach suppression is scoped as tightly as possible — a
_CCCL_DIAG_PUSH/_CCCL_DIAG_SUPPRESS_GCC("-Wnull-dereference")/_CCCL_DIAG_POPbracket around only the offending statement(s)._CCCL_DIAG_SUPPRESS_GCCexpands to a no-op on all non-GCC compilers.Changes
libcudacxx/test/CMakeLists.txt— adds-Wnull-dereferencetoheadertest_warning_levels_device(NVIDIA/NVCC, Clang-as-device, and generic paths) andheadertest_warning_levels_host(non-MSVC). MSVC paths are unchanged.libcudacxx/include/cuda/__utility/__basic_any/virtcall.h— suppresses false positive in__virtcallat the virtual dispatch call site.libcudacxx/include/cuda/__utility/__basic_any/basic_any_value.h— suppresses false positives inreset()andtype()around the__query_interface(__iunknown())dereference chains.libcudacxx/include/cuda/__utility/__basic_any/rtti.h— suppresses false positive in__try_vptr_castslow-path (down-cast / cross-cast) whererttiis known non-null by the__iunknownregistration invariant.Checklist