isuckatcs added inline comments.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho.
Herald added a project: All.


================
Comment at: test/Analysis/casts.c:166
+  *x = 1;
+  clang_analyzer_eval(u == 1); // expected-warning{{TRUE}}
+}
----------------
@NoQ why is this true for both x86_64 and i386? 

On x86_64 `sizeof(int *) == 8` and `sizeof(int) == 4`. This means that `(*((int 
*)(&x))) = (int)&u;` writes to the lower 4 bytes of `x` and leaves the upper 4 
bytes uninitialized. See this [[ https://godbolt.org/z/E6ocPE9Gr | godbolt 
example ]]. If I compile and run this function on my machine it segfaults.

On i386 `sizeof(int *) == 4` and `sizeof(int) == 4`, so on that platform this 
example is correct. See on [[https://godbolt.org/z/GaW73Wod7 | godbolt]].

In the x86_64 case don't we want the analyzer to report a warning a instead, as 
on that platform `u` is only partially initialized?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D46415/new/

https://reviews.llvm.org/D46415

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to