[LLVMbugs] [Bug 22776] New: combination of -march=native and -O1/2/3 causes "illegal instruction" error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 3 16:36:30 PST 2015


            Bug ID: 22776
           Summary: combination of -march=native and -O1/2/3 causes
                    "illegal instruction" error
           Product: clang
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stbudach at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13983
  --> http://llvm.org/bugs/attachment.cgi?id=13983&action=edit
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;
    for(size_t i = 0; i < len; ++i)
    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.

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/20150304/6bf7690c/attachment.html>

More information about the llvm-bugs mailing list