Skip to content

[clang] Missing diagnostic when return a local vector as a span #108463

@usx95

Description

@usx95

https://godbolt.org/z/zes3e9jfr

This is a new false negative

#include<string>
#include <vector>

template <typename T>
struct [[gsl::Owner]] StatusOr {
  const T &value() [[clang::lifetimebound]];
};

template<typename T>
struct [[gsl::Pointer]] Span {
    Span(const std::vector<T> &V): V(V){}
    const std::vector<T> &V;
};

// Pointer<Owner<Pointer>>> from Owner<Pointer>
Span<int*> test9(std::vector<int*> V) {
  return V; // No diagnsotic
}

cc @hokein

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerworksformeResolved as "works for me"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions