Files
clang-p2996/compiler-rt/test/msan/__strxfrm_l.cpp
Dokyung Song 10aa0d7bbc [compiler-rt] Fix compiler warnings and runtime errors in sanitizer RT strxfrm(_l) test cases.
Summary: Fixed an implicit definition warning by including <string.h>. Also fixed run-time assertions that the return value of strxfrm_l calls is less than the buffer size by increasing the size of the referenced buffer.

Reviewers: morehouse

Reviewed By: morehouse

Subscribers: dberris, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D83593
2020-07-13 22:35:01 +00:00

20 lines
480 B
C++

// RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t && %run %t
// REQUIRES: x86_64-linux
#include <assert.h>
#include <locale.h>
#include <sanitizer/msan_interface.h>
#include <stdlib.h>
#include <string.h>
extern "C" decltype(strxfrm_l) __strxfrm_l;
int main(void) {
char q[100];
locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
size_t n = __strxfrm_l(q, "qwerty", sizeof(q), loc);
assert(n < sizeof(q));
__msan_check_mem_is_initialized(q, n + 1);
return 0;
}