Clang in Xcode 7.3 generates illegal SSE instructions

Number:rdar://25704040 Date Originated:13-Apr-2016 05:31 PM
Status:Open Resolved:No
Product:Xcode Product Version:7.3
Classification:Crash Reproducible:Always
The new clang compiler included in Xcode 7.3 (APPLE LLVM version 7.3.0 (clang-703.0.29))
generates invalid SSE instructions (alignment requirements are not satisfied).
It is a regression since Xcode 7.2 (APPLE LLVM version 7.0.2 (clang-700.1.81)),
the attached code works well with previous versions.

For the attached code it generates wrong code for the move-constructor of the map.
It calls movaps instruction with a not aligned memory address if the original map is not empty.

When compiling Without optimizations (-O0), it works.
If the g() function is inlined into main (explicitly calling the move constructor) then it
works with -O0 and -O1 but still crashes with -O2 and -O3.

If the alignment requirement of struct X is decreased to 8 then it works as well.
If X is replaced with std::function<void()> then it crashes as well.

The same code works on Linux with upstream Clang 3.7.0 and 3.8.0 as well. (In this example it generates movups instruction instead of movaps)

Steps to Reproduce:
1. Download the attached bug.cpp file
2. Compile it: "clang++ -std=c++11 -O1 -o bug bug.cpp"
3. Run the compiled program: "./bug"

Expected Results:
It does not crash.

Actual Results:
It does crash with Segmentation Fault 11 (#GP).

Xcode 7.3 (7D175), OS X El Capitan (10.11.4)


The clang in Xcode 7.3 always generates wrong code for x64 architecture.

'bug.cpp' was successfully uploaded.


#include <map>

struct alignas(16) X

std::map<int, X> g()
    std::map<int, X> x{{0, {}}};
    return std::move(x);

int main(void)
    return 0;

Marked as duplicate of 24866513 (Open)


Fixed in Xcode 8.3 beta

By laszlo.agardi.t at March 1, 2017, 8:45 a.m. (reply...)

This issue still exists in Xcode 8 with Apple LLVM version 8.0.0 (clang-800.0.38)

By laszloagardi at Sept. 15, 2016, 3:31 p.m. (reply...)

This issue still exists in Xcode 7.3.1.

By laszlo.agardi.t at May 5, 2016, 6:20 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!