https://bugs.llvm.org/show_bug.cgi?id=42096
Bug ID: 42096
Summary: Inplace new-ing an array overwrites the square of the
memory
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
When in-place new-ing a local variable of an array of trivial type, the
generated code calls 'memset' with the square of the size of the array,
corrupting the stack.
Quick example:
#include <new>
template <typename TYPE>
void f()
{
typedef TYPE TArray[7];
TArray x;
new(&x) TArray();
}
int main()
{
f<char>();
f<int>();
}
Sample code generation can be seen for Clang 7 and 8 via godbolt:
https://godbolt.org/z/WjhFrc
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs