[Issue 17220] invalid code with -m32 -inline and struct that's 4x the size of an assigned enum value

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17220

Stefan Koch  changed:

   What|Removed |Added

   Hardware|x86 |x86_64

--- Comment #1 from Stefan Koch  ---
Happens on 64bit as well
Slightly modified:

void emitArithInstruction2(BCValue lhs)
{
if (lhs.type != BCTypeEnum.i32) // type get's overwritten
assert(0);
}

enum BCTypeEnum : ubyte
{
Undef,
i32 = 8, // value must be >= 8
}

struct BCValue // size must be size_t.sizeof x BCTypeEnum.i32
{
BCTypeEnum type; // position doesn't matter
ubyte[size_t.sizeof * BCTypeEnum.i32 - type.sizeof] more;
}
static assert(BCValue.sizeof == size_t.sizeof * BCTypeEnum.i32);

BCValue i32()
{
BCValue result; // must be default 0 initialized
result.type = BCTypeEnum.i32; // set value
return result;
}

void main()
{
auto val = i32();
emitArithInstruction2(val);
}
CODE

--


[Issue 17220] invalid code with -m32 -inline and struct that's 4x the size of an assigned enum value

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17220

Stefan Koch  changed:

   What|Removed |Added

 CC||uplink.co...@gmail.com
 OS|Linux   |All
   Severity|normal  |major

--