Skip to content

[LifetimeSafety] provide more details on lifetimebound violation #209763

Description

@firewave
#include <vector>

struct S
{
    S(const std::vector<int>& v); // missing annotation
};

S f2(const std::vector<int>& v [[clang::lifetimebound]])
{
    return {v}; // actual violation location
}

S f1(const std::vector<int>& v [[clang::lifetimebound]])
{
    return f2(v);
}
<source>:8:34: warning: could not verify that the return value can be lifetime bound to 'v' [-Wlifetime-safety-lifetimebound-violation]
    8 | S f2(const std::vector<int>& v [[clang::lifetimebound]])
      |                                  ^~~~~~~~~~~~~~~~~~~~

https://godbolt.org/z/Wex6xaW1n

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)enhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions