<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - When vswscanf function is used, an error occurred in the execution result."
href="https://bugs.llvm.org/show_bug.cgi?id=43781">43781</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>When vswscanf function is used, an error occurred in the execution result.
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ueno.masakazu@jp.fujitsu.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>When vswscanf function is used, an error occurred in the execution result.
* Case 1
$ clang -O3 test.c -fno-omit-frame-pointer -Wall
$ ./a.out
(1)-----
1 = 50
2 = aaa
num = 2
(2)-----
1 = 0 **Like GCC, it is expected that 20 will be output.
2 = bbb
(3)-----
1 = 0 **Like GCC, it is expected that 20 will be output.
2 = bbb
* Case 2
$ clang -O3 test.c -fomit-frame-pointer -Wall
$ ./a.out
(1)-----
1 = 50
2 = aaa
num = 2
(2)-----
1 = 20
2 = bbb
(3)-----
1 = 20
2 = bbb
Segmentation fault ** Expect to complete normally.
* test.c
-------------------
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
void sub(int a, ...)
{
va_list ap;
int n;
long ll;
va_start(ap, a);
ll = (long)*(va_arg(ap, long *));
printf("(1)-----\n");
printf(" 1 = %ld \n", ll);
printf(" 2 = %s \n", va_arg(ap, char *));
va_end(ap);
va_start(ap, a);
n = vswscanf(L"20 bbb", L"%d%s", ap);
printf(" num = %d \n",n);
va_end(ap);
va_start(ap, a);
ll = (long)*(va_arg(ap, long *));
printf("(2)-----\n");
printf(" 1 = %ld \n", ll);
printf(" 2 = %s \n", va_arg(ap, char *));
va_end(ap);
}
int main()
{
long ll=50;
char name[] = {"aaa"};
sub(4,&ll,name);
printf("(3)-----\n");
printf(" 1 = %ld \n", ll);
printf(" 2 = %s \n", name);
return 0;
}
-------------------</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>