Issue 165900
Summary in `clang-analyzer`, `StackAddressEscape` has problems with out-of-line destructors
Labels new issue
Assignees
Reporter jmcclellan-figma
    The following code:

```
struct A {
  int& x;
};

struct B {
  A a;
  B(A a) : a{a} {}
  ~B();
};

static B getA() {
  int x;
  return B{A{.x = x}};
}

B::~B() = default;
```

incorrectly passes clang tidy with `--checks=clang-analyzer-core.StackAddressEscape`.

However, this very similar code correctly triggers the warning.

```
struct A {
  int& x;
};

struct B {
  A a;
  B(A a) : a{a} {}
};

static B getA() {
 int x;
  return B{A{.x = x}};
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to