https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106391
Bug ID: 106391 Summary: Support gsl::not_null in -fanalyzer Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Blocks: 97110 Target Milestone: --- Support the gsl::not_null<T> class template, which is a no-op wrapper around a pointer (or smart pointer) that just informs readers and static analyzers that the container pointer is never null. See https://github.com/microsoft/GSL/blob/330583f47800c60cf001239550d291d16274756a/include/gsl/pointers#L69 for the reference impl, although I intend to add an impl to libstdc++ too. This might be unnecessary if the libstdc++ implementation makes use of GCC __attribute__((nonnull)), as the analyzer would just handle that automatically. But that might only work for raw pointers, and couldn't be used to say gsl::not_null<unique_ptr<T>> to express the intent that a smart pointer is never empty? So maybe worth adding explicit support to the analyzer? More research needed. See https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gslview-views for more details. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97110 [Bug 97110] [meta-bug] tracker bug for supporting C++ in -fanalyzer