[LLVMbugs] [Bug 23528] New: On Windows clang produce bad binary for global 4-element double array and __builtin_shufflevector

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 14 12:27:35 PDT 2015


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

            Bug ID: 23528
           Summary: On Windows clang produce bad binary for global
                    4-element double array and __builtin_shufflevector
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gdimitron at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14330
  --> https://llvm.org/bugs/attachment.cgi?id=14330&action=edit
Visual Studio 2013 access violation with dissam window screenshot;

Latest clang 3.7 for Windows (LLVM-3.7.0-r237002-win32) produce bad binary for
program:

#include <stdio.h>
#define N 4
typedef double VecTy __attribute__((__vector_size__( sizeof(double) * N)));
double L[] = { 2.5, -0.1, 0.9, 5.1 };

int main(void) {
  VecTy *L_vec = (VecTy*)L;
  VecTy res = __builtin_shufflevector(*L_vec, *L_vec, 1, 2, 3, 0);

  for (int i = 0; i < sizeof(res)/sizeof(res[0]); i++) {
    printf("%f ", res[i]);
  }
}


Build: clang -g VecShuffle.cpp

Actual result, Windows 7 64bit (under Visual Studio):
See attached vs_access_violation.png

Actual result, Windows 7 64bit (under gdb):
>gdb a.exe
(gdb) run
Starting program: C:\workfolder\clang_tests\a.exe
[New Thread 10552.0x323c]
Program received signal SIGSEGV, Segmentation fault.


Expected result: the same on linux(redhat) -
 ./a.out
-0.100000 0.900000 5.100000 2.500000


Note: If you move L[] inside main block, the result on windows will be correct:
C:\workfolder\clang_tests>a.exe
-0.100000 0.900000 5.100000 2.500000

-- 
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/20150514/ca90eedb/attachment.html>


More information about the llvm-bugs mailing list