<html>
    <head>
      <base href="http://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 --- - combination of -march=native and -O1/2/3 causes "illegal instruction" error"
   href="http://llvm.org/bugs/show_bug.cgi?id=22776">22776</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>combination of -march=native and -O1/2/3 causes "illegal instruction" error
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>stbudach@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=13983" name="attach_13983" title="test file to reproduce the error">attachment 13983</a> <a href="attachment.cgi?id=13983&action=edit" title="test file to reproduce the error">[details]</a></span>
test file to reproduce the error

#include <iostream>
#include <string>
#include <random>

std::string generateRandomString(size_t len)
{
    std::string alphabet = "ACGT";
    std::random_device rd;
    std::default_random_engine rng(rd());
    std::uniform_int_distribution<int> dist (0, alphabet.size()-1);

    std::string randomString;
    randomString.reserve(len);
    for(size_t i = 0; i < len; ++i)
        randomString.push_back(alphabet[dist(rng)]);
    return randomString;
}

int main()
{
    std::cout << generateRandomString(20) << '\n';
}

When compiling the code with "clang++ -std=c++11 -march=native -O3 -o test
test.cpp" I get no compiler errors, but the binary crashes with an "illegal
instruction". Using -march=native and -O1/2/3 separately works fine, just the
combination triggers the error (with clang++ 3.5 and 3.6 on Ubuntu 14.04).

My CPU is an i3-4000M, and clang recognizes it as -target-cpu core-avx2.</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>