From 4238cd5dd7d3e54ea372c6dc4fc06c2ccd10a63b Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sun, 25 Nov 2018 19:38:02 +0000 Subject: [MetadataTest] Fix off-by-one strncpy warning reported by gcc8. (NFC) llvm-svn: 347528 --- llvm/unittests/IR/MetadataTest.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'llvm/unittests/IR/MetadataTest.cpp') diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index b2ffb80b15e..3f744cd5e6d 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -147,11 +147,9 @@ TEST_F(MDStringTest, CreateSame) { // Test that MDString prints out the string we fed it. TEST_F(MDStringTest, PrintingSimple) { - char *str = new char[13]; - strncpy(str, "testing 1 2 3", 13); - MDString *s = MDString::get(Context, StringRef(str, 13)); - strncpy(str, "aaaaaaaaaaaaa", 13); - delete[] str; + char str[14] = "testing 1 2 3"; + MDString *s = MDString::get(Context, StringRef(&str[0], 13)); + strncpy(str, "aaaaaaaaaaaaa", 14); std::string Str; raw_string_ostream oss(Str); -- cgit v1.2.3