https://bugs.llvm.org/show_bug.cgi?id=48624

            Bug ID: 48624
           Summary: Miscompilation of va_start on Windows MSYS2
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Not sure if this is a Clang bug or a MSYS2 bug, so I am filing it here.


However, since the problem doesn't affect GCC which links to the same libc, I
am assuming it is something fishy with clang.

Compile this rather simple C program on MSYS2:


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

void my_printf(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    vprintf(fmt, ap);
    va_end(ap);
}

int main(void)
{
    my_printf("%s\n", "Hello, world!");
}

***@**** MSYS2 ~
$ clang --version
clang version 11.0.0 (https://github.com/msys2/MSYS2-packages
a5a028a0811f03c8f9697bf80c2e28111628ffff)
Target: x86_64-pc-windows-msys
Thread model: posix
InstalledDir: /usr/bin

***@**** MSYS2 ~
$ clang test.c; ./a.exe
0@

***@**** MSYS2 ~
$./a.exe | hexdump -C
00000000  04 30 40 0a                                       |.0@.|
00000004

In case you are wondering, GCC correctly compiles this; my libc isn't broken.

***@**** MSYS2 ~
$ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

***@**** MSYS2 ~
$ gcc test.c; ./a.exe
Hello, world!

It doesn't matter if optimizations are on or off, it still prints 0x04 0x30
0x40.

mingw-w64 clang compiles it fine, though. 

Doing some more investigation now, although I am not familiar with the calling
convention.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to