public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/61483] New: [AArch64] builtin va_start incorrectly initializes the field of va_list for incoming unnamed arguments on the stack
@ 2014-06-12 11:23 yufeng at gcc dot gnu.org
  2014-06-12 11:24 ` [Bug target/61483] " yufeng at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: yufeng at gcc dot gnu.org @ 2014-06-12 11:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61483

            Bug ID: 61483
           Summary: [AArch64] builtin va_start incorrectly initializes the
                    field of va_list for incoming unnamed arguments on the
                    stack
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yufeng at gcc dot gnu.org

The following code is mis-compiled by gcc, when targeting aarch64. The issue is
that the second variadic argument to callee_b0f, which is of type long long, is
not retrieved correctly inside the callee.

------------------- CODE -------------------
#include <stdarg.h>
#include <stdio.h>

struct float_float_t { float a, b;  } float_float = {1.2, 2.2};

union float_int_t {
    float b8;
    int b5;
} float_int = {4983.80};

long long correct = 12683143434LL;

long long callee_b0f(float f1, float f2, float f3, float f4,
                float f5, float f6, float f7, struct float_float_t ff,
                int i1, int i2, int i3, int i4,
                int i5, int i6, int i7,
                ...) {
    va_list ap;
    va_start(ap, i7);

    va_arg(ap, union float_int_t);
    long long var = va_arg(ap, long long);

    va_end(ap);

    return var;
}

int main()
{
    long long check = callee_b0f(1.0, 2.0, 3.0, 4.0,
                                 5.0, 6.0, 7.0, float_float,
                                 9, 10, 11, 12,
                                 13, 14, 15,
                                 float_int, correct);
    printf("%lld\n%lld\n", correct, check);
    return 0;
}

------------------- CUT -------------------

Expected output:

12683143434
12683143434

Actual output:

12683143434
0

I have checked that this bug is present since 4.8.0 (day one of the aarch64
port).


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-17 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 11:23 [Bug target/61483] New: [AArch64] builtin va_start incorrectly initializes the field of va_list for incoming unnamed arguments on the stack yufeng at gcc dot gnu.org
2014-06-12 11:24 ` [Bug target/61483] " yufeng at gcc dot gnu.org
2014-06-12 11:25 ` yufeng at gcc dot gnu.org
2014-06-17  9:40 ` yufeng at gcc dot gnu.org
2014-06-17 14:15 ` yufeng at gcc dot gnu.org
2014-06-17 14:19 ` yufeng at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).