[llvm-bugs] [Bug 43781] New: When vswscanf function is used, an error occurred in the execution result.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 23 23:51:50 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43781

            Bug ID: 43781
           Summary: When vswscanf function is used, an error occurred in
                    the execution result.
           Product: new-bugs
           Version: unspecified
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ueno.masakazu at jp.fujitsu.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

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;
}
-------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191024/f2260834/attachment-0001.html>


More information about the llvm-bugs mailing list