[Issue 8778] New: Struct with core.simd type has wrong size and gives Segmentation fault
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 7 22:21:02 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8778
Summary: Struct with core.simd type has wrong size and gives
Segmentation fault
Product: D
Version: 2.041
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: malteskarupke at web.de
--- Comment #0 from Malte Skarupke <malteskarupke at web.de> 2012-10-07 22:08:58 PDT ---
I have this problem in version 2.060 (but I had to select 2.041 because that's
the newest version in the bug tracker)
I'm also not sure whether this should be two bugs or one, but they seem related
so I'm posting them as one.
I wanted to write a Vector4 struct which gives operator overloads for simple
SIMD instructions. But the compiler behaves weird in that a) the struct has the
wrong size, and b) it gives me segmentation faults if I make the struct pure
nothrow @safe.
void main()
{
import core.simd;
struct PureVector4
{
pure:
nothrow:
@safe:
PureVector4 opAdd(in PureVector4 rhs) const
{
PureVector4 toReturn;
toReturn.xyzw = __simd(XMM.ADDPS, xyzw, rhs.xyzw);
return toReturn;
}
float4 xyzw;
}
struct Vector4
{
Vector4 opAdd(in Vector4 rhs) const
{
Vector4 toReturn;
toReturn.xyzw = __simd(XMM.ADDPS, xyzw, rhs.xyzw);
return toReturn;
}
float4 xyzw;
}
static assert(PureVector4.sizeof == Vector4.sizeof); // doesn't compile the
pure one is size 16 (correct), the other one is size 32 (incorrect)
PureVector4 vec; // Segmentation fault. would work with the non-pure one
vec.xyzw.array = [1, 2, 3, 1]; // just need to use the vector from the
previous line, otherwise there is no Segmentation fault
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list