<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - On Windows clang produce bad binary for global 4-element double array and __builtin_shufflevector"
   href="https://llvm.org/bugs/show_bug.cgi?id=23528">23528</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>On Windows clang produce bad binary for global 4-element double array and __builtin_shufflevector
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gdimitron@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14330" name="attach_14330" title="Visual Studio 2013 access violation with dissam window screenshot;">attachment 14330</a> <a href="attachment.cgi?id=14330&action=edit" title="Visual Studio 2013 access violation with dissam window screenshot;">[details]</a></span>
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):
<span class="quote">>gdb a.exe</span >
(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</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>