Hi, cfe-commits,

When I run gcc testsuite pr44575.c on clang, then I found a stack overflow
issue.
The root cause is since it want to copy {double, double} (16-byte) back to
stack but clang only allocate float[3] (12-byte) in this case.
It happens after release 3.4, and I found this is modified at this commit:


    commit eeb00624413d4a4856e66809b84c558d2cdce17f
Author: Eli Friedman <[email protected]>
Date:   Fri Jun 7 23:20:55 2013 +0000

    Fix va_arg on x86-64 for a struct containing a single int128_t.  PR16248

    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183590
91177308-0d34-0410-b5e6-96231b3b80d8

Could somebody please have a look? Thanks!

If you want to reproduce, you can just use this simple code and found var i
will be changed after va_arg extraction.

     1  /* PR target/44575 */
     2  // clang -O0 reduced.c && ./a.out
     3  #include <stdarg.h>
     4
     5  struct S { float a[3]; } a;
     6
     7  void
     8  check (int z, ...)
     9  {
    10    va_list ap;
    11    int i = 0x5566;
    12    va_start (ap, z);
    13    va_arg (ap, struct S);
    14    if (i != 0x5566)
    15      abort();
    16  }
    17
    18  int
    19  main ()
    20  {
    21    a.a[2] = -49026;
    22    check (1, a);
    23    return 0;
    24  }


-- 
Best Regards,
WenHan Gu (Nowar)

Attachment: 0001-3.5-x86_64-Bugfix-for-va_arg-when-neededSSE-2-to-pre.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to