From c7b993b4dfc14ca2389087f21467259de8af7e91 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 16 Jun 2011 04:13:47 +0000 Subject: [PATCH] Fix my test case from r133136 so that it actually represents the code 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/SemaCXX/warn-memset-bad-sizeof.cpp b/test/SemaCXX/warn-memset-bad-sizeof.cpp index 167f05f3da..b334500ef5 100644 --- a/test/SemaCXX/warn-memset-bad-sizeof.cpp +++ b/test/SemaCXX/warn-memset-bad-sizeof.cpp @@ -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)); -- 2.40.0