c++ - move-assigning a std::map with an aligned value type segfaults -
the following code segfaults consistently me on clang 3.8 succeeds on clang 3.7. compile clang++ -std=c++14 -o2 test_case.cpp -o test_case
in both cases. if compile optimisations off on clang 3.8 program runs completion.
i'm guessing compiler taking liberties when optimising - question is: compiler allowed optimise in way, or have found first compiler bug?
#include <iostream> #include <map> struct __attribute__((aligned(16))) troublesome { float s; }; int main() { std::map<int, troublesome> m{{0, troublesome{}}}; std::map<int, troublesome> n{{1, troublesome{}}}; std::cout << "got here" << std::endl; // prints m = std::move(n); // segfault happens here std::cout << "got here too" << std::endl; // here on old clang }
Comments
Post a Comment