C++ 函数Simd::Fill()的奇怪行为
我使用来自的函数。而且它在大多数情况下都能正常工作。但有时会有一种奇怪的行为。例如,在这种情况下:C++ 函数Simd::Fill()的奇怪行为,c++,memory-corruption,simd-library,C++,Memory Corruption,Simd Library,我使用来自的函数。而且它在大多数情况下都能正常工作。但有时会有一种奇怪的行为。例如,在这种情况下: #include "Simd/SimdLib.hpp" typedef Simd::View<Simd::Allocator> View; View Create(size_t w, size_t h, uint8_t color) { View image(w, h, View::Gray8); Simd::Fill(image, color); retu
#include "Simd/SimdLib.hpp"
typedef Simd::View<Simd::Allocator> View;
View Create(size_t w, size_t h, uint8_t color)
{
View image(w, h, View::Gray8);
Simd::Fill(image, color);
return image;
}
int main()
{
View image;
image = Create(200, 150, 127);
image.Save("image.pgm");
return 0;
}
#包括“Simd/SimdLib.hpp”
typedef Simd::视图;
视图创建(大小w、大小h、uint8颜色)
{
视图图像(w、h、视图::灰色8);
Simd::填充(图像、颜色);
返回图像;
}
int main()
{
查看图像;
图像=创建(200150127);
image.Save(“image.pgm”);
返回0;
}
已保存的“image.pgm”:
图像中有一种奇怪的噪音。这类似于内存损坏,但我找不到它在哪里。有人能帮我吗?看来我发现了一个导致这种行为的错误。 类的赋值运算符仅将引用赋值给其他图像。因此,函数Create()返回对本地对象的引用
为了创建Simd::View的副本,必须使用函数或方法 哦。这是我的错。非常感谢。