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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to