[llvm-bugs] [Bug 24957] New: alignas with placement new operator generate invalid instruction with sse
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 28 00:48:26 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24957
Bug ID: 24957
Summary: alignas with placement new operator generate invalid
instruction with sse
Product: clang
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: llvm at gyoo.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
When using alignas, clang will generate the mmx instruction if O1 optimization
or greater are used:
movaps %xmm0,(%rbx)
But if the memory has been allocated with a new placement operator on a non
16-bytes alignment, it will crash with a coredump
Here a test case:
// clang -std=c++11 -lstdc++ -O0 -g align.cc # ok
// clang -std=c++11 -lstdc++ -O1 -g align.cc # coredump because of
MOVAPS on non-aligned 128 bits
// clang -std=c++11 -lstdc++ -O1 -mno-sse -g align.cc # no more coredump
#include <iostream>
constexpr static int ALIGN_SIZE = 64;
class MyStruct
{
public:
MyStruct()
{
std::cout << "MyStruct: " << this << " " << sizeof(*this) << std::endl
<< "m_v1: " << &m_v1 << ", m_v2: " << &m_v2 << std::endl;
m_v1 = 0;
m_v2 = 0;
}
private:
alignas(ALIGN_SIZE) uint64_t m_v1;
uint64_t m_v2;
};
int main()
{
size_t offset = 1; // offset not a multiplier of 16 will crash
char* ptr = new char[sizeof(MyStruct) + offset];
MyStruct* myStruct = new (ptr+offset) MyStruct;
return 0;
}
--
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/20150928/6725c8c0/attachment.html>
More information about the llvm-bugs
mailing list