]> granicus.if.org Git - clang/commitdiff
Fix my test case from r133136 so that it actually represents the code
authorChandler Carruth <chandlerc@gmail.com>
Thu, 16 Jun 2011 04:13:47 +0000 (04:13 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 16 Jun 2011 04:13:47 +0000 (04:13 +0000)
pattern found in the wild where this warning was firing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133143 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/warn-memset-bad-sizeof.cpp

index 167f05f3daff98775ba182bc3cc1448fcebc0464..b334500ef5c63af5426c16c53c1291f214cd8a90 100644 (file)
@@ -23,11 +23,10 @@ inline Dest bit_cast(const Source& source) {
 }
 
 // http://www.lysator.liu.se/c/c-faq/c-2.html#2-6
-void f(Mat m, const Foo& const_foo) {
+void f(Mat m, const Foo& const_foo, char *buffer) {
   S s;
   S* ps = &s;
   PS ps2 = &s;
-  char c = 42;
   char arr[5];
   char* parr[5];
   Foo foo;
@@ -68,8 +67,9 @@ void f(Mat m, const Foo& const_foo) {
   memcpy(&foo, &const_foo, sizeof(Foo));
   memcpy((void*)&s, 0, sizeof(&s));
   memcpy(0, (void*)&s, sizeof(&s));
-  memcpy(&parr[3], &c, sizeof(&c));
-  memcpy((char*)&parr[3], &c, sizeof(&c));
+  char *cptr;
+  memcpy(&cptr, buffer, sizeof(cptr));
+  memcpy((char*)&cptr, buffer, sizeof(cptr));
 
   CFooRef cfoo = foo;
   memcpy(&foo, &cfoo, sizeof(Foo));