xref: /aosp_15_r20/external/compiler-rt/test/msan/strerror_r-non-gnu.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clang_msan -std=c99 -O0 -g %s -o %t && %run %t
2*7c3d14c8STreehugger Robot 
3*7c3d14c8STreehugger Robot // strerror_r under a weird set of circumstances can be redirected to
4*7c3d14c8STreehugger Robot // __xpg_strerror_r. Test that MSan handles this correctly.
5*7c3d14c8STreehugger Robot 
6*7c3d14c8STreehugger Robot #define _POSIX_C_SOURCE 200112
7*7c3d14c8STreehugger Robot #include <assert.h>
8*7c3d14c8STreehugger Robot #include <stdio.h>
9*7c3d14c8STreehugger Robot #include <string.h>
10*7c3d14c8STreehugger Robot #include <errno.h>
11*7c3d14c8STreehugger Robot 
main()12*7c3d14c8STreehugger Robot int main() {
13*7c3d14c8STreehugger Robot   char buf[1000];
14*7c3d14c8STreehugger Robot   int res = strerror_r(EINVAL, buf, sizeof(buf));
15*7c3d14c8STreehugger Robot   assert(!res);
16*7c3d14c8STreehugger Robot   volatile int z = strlen(buf);
17*7c3d14c8STreehugger Robot   return 0;
18*7c3d14c8STreehugger Robot }
19