[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 10 05:56:33 PST 2021


steakhal added a comment.

I'm looking forward to this patch.



================
Comment at: clang/test/Analysis/string.c:367-373
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char *)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
----------------
steakhal wrote:
> I would prefer slightly more readbale names.
> `func_strcpy_no_assertion()` -> `get_void_ptr()`
> `ptr_strcpy_no_assertion ` -> `type_punned_ptr`
> `no-assertion` -> `no-crash`
> You could also hoist the `char a` as a function parameter to spare a line :)
I think this is 'done'. :)


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

https://reviews.llvm.org/D89055



More information about the cfe-commits mailing list