[llvm-bugs] [Bug 48624] New: Miscompilation of va_start on Windows	MSYS2
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Tue Dec 29 11:51:38 PST 2020
    
    
  
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: unassignedclangbugs at nondot.org
          Reporter: husseydevin at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk
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 at .|
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201229/5a3a00c9/attachment.html>
    
    
More information about the llvm-bugs
mailing list