Closed
Description
Bugzilla Link | 42096 |
Version | 8.0 |
OS | Linux |
CC | @dwblaikie,@DougGregor,@jfbastien,@riccibruno,@zygoloid |
Extended Description
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