[LLVMbugs] [Bug 17789] New: Incorrect code of variable arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Nov 3 07:22:17 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=17789

            Bug ID: 17789
           Summary: Incorrect code of variable arguments
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ishiura-compiler at ml.kwansei.ac.jp
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang 3.4 (based on LLVM 3.4svn) for i386 target miscompiles the following
code.

    $ cat error.c

    #include <stdarg.h>

    struct triple_s { short a; short b; short c; };

    void func(struct triple_s s, ... );

    int main(void)
    {
            struct triple_s s = { 1, 1, 1 };
            int x = 1;

            func(s, x);

            return 0;
    }

    void func(struct triple_s s, ... )
    {
            int x;

            va_list ap;
            va_start(ap, s);
            x = va_arg(ap, int);
            va_end(ap);

            if( x != 1 ) { __builtin_abort(); }
    }

    $ clang error.c
    $ ./a.out
    Aborted (core dumped)

The value of x was 65556 instead of 1.
There was no problem with an x86_64 target (but fails with -m32 option).

-- 
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/20131103/a36fc795/attachment.html>


More information about the llvm-bugs mailing list