[PATCH] [analyzer] Do not reinitialize static globals when the function is called more than once along a path

Ted Kremenek kremenek at apple.com
Wed Feb 6 15:27:49 PST 2013

On Feb 6, 2013, at 3:24 PM, Ted Kremenek <kremenek at apple.com> wrote:

> Put another way, this patch seems to rely on the value of a variable being "uninitialized" to indicate whether or not the initializer has been executed.  That's not a valid assumption.  For example:
>   static id x = foo(x);
> is "okay" in Objective-C.

… or rather Objective-C++.

$ cat t.mm
#include <stdio.h>

id foo(id x) {
  printf("%p\n", x);
  return x;

int main() {
  static id x = foo(x);

$ clang++ t.mm
$ ./a.out
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/2510cdcc/attachment.html>

More information about the cfe-commits mailing list