xref: /llvm-project/compiler-rt/test/sanitizer_common/TestCases/scanf.c (revision ad7e2501000da2494860f06a306dfe8c08cc07c3)
1 // RUN: %clang -std=c17 %s -o %t && %run %t
2 /// Test __isoc23_* for glibc 2.38+.
3 // RUN: %clang -std=c23 %s -o %t && %run %t
4 
5 #include <assert.h>
6 #include <stdarg.h>
7 #include <stdio.h>
8 
test_vsscanf(const char * buf,const char * fmt,...)9 int test_vsscanf(const char *buf, const char *fmt, ...) {
10   va_list ap;
11   va_start(ap, fmt);
12   int ret = vsscanf(buf, fmt, ap);
13   va_end(ap);
14   return ret;
15 }
16 
main(int argc,char ** argv)17 int main(int argc, char **argv) {
18   int x, y;
19   assert(sscanf("42", "%d", &x) == 1);
20   assert(x == 42);
21   assert(test_vsscanf("42", "%d", &y) == 1);
22   assert(y == 42);
23   return 0;
24 }
25