Inlining temporary destructors in the analyzer

Message: 4
Date: Wed, 30 Jul 2014 17:14:44 +0200
From: Manuel Klimek<klimek@google.com>
To: Jordan Rose<jordan_rose@apple.com>
Cc: clang-dev Developers<cfe-dev@cs.uiuc.edu>
Subject: [cfe-dev] Inlining temporary destructors in the analyzer
Message-ID:
  <CAOsfVvnZ6i8t8=0RN-ko87szZfh5V8wqBP7AKMR2QNMYU0O5tA@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Jordan,

I made some progress on inlining temporary destructors. My main problem
currently is that somehow the initializer values in my constructor get lost
if I don't also reference 'this' via some other way.

An examples shows that best. Consider:
struct A {
   A(int* y) : z(y) {}
   ~A() { *z = 23; }
   int *z;
};
void f() {
   int x = 0;
   {(A(&x));}
}

This leads to a "Dereference of undefined pointer value" warning on *z = 23.

This is a great warning, well done to the authors and designers! Apparently the compiler is detecting this will crash if y == 0. It seems pretty good as is to me. It's an open question how far to go to process questionable coding practices. Example the (void) this; below, would that ever happen in the wild?