Skip to content

No dangling warnings on gsl::pointer-type function parameter with the lifetimebound attribute #100549

@hokein

Description

@hokein

These are real cases, it would be nice to capture them in clang.

Case1:

class UrlAnalyzed {
  public:
    UrlAnalyzed(string_view url [[clang::lifetimebound]]);
};

std::string StrCat(std::string_view, std::string_view);

void test() {
    UrlAnalyzed url(StrCat("abc", "bcd")); // dangling!
}

Case2:

std::string_view ReturnStringView(std::string_view abc [[clang::lifetimebound]]);

void test() {
    std::string_view sv1 = ReturnStringView(StrCat("bar", "x")); // dangling
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions