[LLVMbugs] [Bug 14792] New: va_start is not computed correctly on x86 and x86-32

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 4 09:54:39 PST 2013


             Bug #: 14792
           Summary: va_start is not computed correctly on x86 and x86-32
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: tjablin at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 9802
  --> http://llvm.org/bugs/attachment.cgi?id=9802

In llvm 3.3 (trunk 171467), va_start is not computed correctly on x86 and
x86-64 when the first two arguments are passed on the stack and the first
argument is not aligned to 4 bytes on x86 or 8 bytes on x86-64. The va_start
pointer arithmetic should account for the alignment of the first parameter, but
does not. A test case follows:

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

struct Foo { char array[24]; };
template<int X> struct Baz { char array[X]; };

static Foo foo = { "                     :("};
static Foo qux = { "GOOD" };

template<class X>
void bar(X x, ...) {
  va_list va;
  va_start(va, x);
  va_arg(va, Foo);
  Foo f = va_arg(va, Foo);

int main(int argc, char **argv) {
  bar(Baz<17>(), foo, qux);
  bar(Baz<21>(), foo, qux);
  bar(Baz<25>(), foo, qux);
  return 0;

The output should be:

Currently, on x86-64:

Currently, on x86:

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list