Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

false-positive [clang-analyzer-deadcode.DeadStores] with reference #46393

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR47424
Status NEW
Importance P enhancement
Reported by Tiago Macarios (tiagomacarios@gmail.com)
Reported on 2020-09-04 13:22:08 -0700
Last modified on 2020-09-05 11:19:08 -0700
Version trunk
Hardware PC Windows NT
CC dcoughlin@apple.com, llvm-bugs@lists.llvm.org, noqnoqneo@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
With the following code [clang-analyzer-deadcode.DeadStores] will report
'b=true' as never read, but ~S() will read it.

https://godbolt.org/z/dqfrc1

#include <iostream>

struct S {
  const bool& m_b;
  S(bool const& b) : m_b(b) {}
  ~S() { std::cout << m_b; }
};

int main() {
  bool b = false;
  S s(b);
  b = true;
}
Quuxplusone commented 4 years ago

Hmm. Indeed. Thanks! I'll see what I can do.