[cfe-dev] Inlining temporary destructors in the analyzer
Tim Toomay
toomayt at toomaytech.com
Wed Jul 30 14:02:52 PDT 2014
On 7/30/2014 9:37 AM, cfe-dev-request at cs.uiuc.edu wrote:
> Message: 4
> Date: Wed, 30 Jul 2014 17:14:44 +0200
> From: Manuel Klimek<klimek at google.com>
> To: Jordan Rose<jordan_rose at apple.com>
> Cc: clang-dev Developers<cfe-dev at cs.uiuc.edu>
> Subject: [cfe-dev] Inlining temporary destructors in the analyzer
> Message-ID:
> <CAOsfVvnZ6i8t8=0RN-ko87szZfh5V8wqBP7AKMR2QNMYU0O5tA at 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?
> Funnily enough this warning goes away (and all values get correctly
> propagated) if change the constructor to be:
> A(int* y) : z(y) { (void)this; }
>
> Obviously this also works fine if I use a local variable instead of a
> temporary.
>
> Any ideas what might be going wrong here would be greatly appreciated.
> Thanks!
> /Manuel
--
Tim Toomay
Toomay Technologies Inc
www.ToomayTech.com
*****
NOTICE OF CONFIDENTIALITY: The information contained in this e-mail and attachment(s), if any, is legally protected pursuant to the Electronic Communications Privacy Act, 18 U.S.C. 2510, et seq., inter alia, and may contain privileged and confidential information. This communication is intended only for the use of each individual named above. If you know, or have any reason to believe, that you are not an intended recipient, you are hereby notified that any dissemination or duplication of this e-mail is prohibited. There is and shall be no waiver of any privilege or confidence by your receipt of this transmission. If you know or have any reason to believe that you received this e-mail in error, please immediately notify us by e-mail or collect telephone call.
More information about the cfe-dev
mailing list