llvm/llvm-project

-Wdangling-field detects view members initalized from a by-value owner parameter

Open

#187675 opened on Mar 20, 2026

View on GitHub
 (8 comments) (1 reaction) (0 assignees)C++ (26,378 stars) (10,782 forks)batch import
clang:temporal-safetygood first issue

Description

struct Foo {};
struct Bar {
  const Foo& foo;
  Bar(Foo f ) : foo(f) {} // good, clang warn on this case
};


struct C {
    string_view s;
    C(std::string c) : s(c) {} // bad, clang doesn't warn on this case. support it
};

Contributor guide