<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55194>55194</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Constructor without visible definition breaks the static analyzer's reasoning about unrelated fields
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          josephcsible
      </td>
    </tr>
</table>

<pre>
    Consider this C++ code:

```cpp
struct SomeStruct {
  SomeStruct() noexcept;
};

//SomeStruct::SomeStruct() noexcept {}

class SomeClass {
  const bool b;
  const SomeStruct s;

public:
  SomeClass() : b(true) {}
  operator bool() const { return b; }
};

void f() {
  int *p = new int;
  if (SomeClass())
    delete p;
}
```

When I run `clang --analyze -Xanalyzer -analyzer-output=text` on it, I get this:

```
q72007867.cpp:20:1: warning: Potential leak of memory pointed to by 'p' [cplusplus.NewDeleteLeaks]
}
^
q72007867.cpp:17:12: note: Memory is allocated
  int *p = new int;
           ^~~~~~~
q72007867.cpp:18:7: note: Assuming the condition is false
  if (SomeClass())
      ^~~~~~~~~~~
q72007867.cpp:18:3: note: Taking false branch
  if (SomeClass())
  ^
q72007867.cpp:20:1: note: Potential leak of memory pointed to by 'p'
}
^
1 warning generated.
```

Uncommenting the definition of `SomeStruct`'s constructor makes the warning go away, though. Swapping the order of `const bool b;` and `const SomeStruct s;` also makes it go away.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVV2PmzoQ_TXkZRTERwjJAw_ZTVeq1HtVaW_VvhozJO46NrXNpumvv2MTNmy2qbbIGOPBc84cz5haN6fqXisrGjTg9sLCfZTdUQOuG4zyTZRso2Tsl8nQeNcNM9aZnjt41Ad8HIZReTeYYDIbZasoW4PS-JNj56L8_E1Ubi_joc8eqE1WEoN8c9NTgCMnEw9cMmsD9n0YTQhxCtRBrbWE-gV3nJ7EYK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