[Issue 14269] Enum is not implicitly converted to base type when using ref
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Mar 10 14:50:54 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14269
--- Comment #16 from Dicebot <public at dicebot.lv> ---
(In reply to Kenji Hara from comment #8)
> (In reply to Dicebot from comment #7)
> > unless it compromises program correctness (memory corruption, wrong
> > codegen etc).
>
> In 2.066 and earlier, the program correctness had been compromised and
> generated wrong code. So the bug should be fixed immediately in the 2.067
> release.
>
> I'm not sure why you think the bug is trivial.
Slightly modified version of original snippet:
enum Bits: ulong
{
none = 0
}
void hasBit(ref ulong rBits,)
{
rBits = 424242;
}
void main()
{
Bits bits;
hasBit(bits);
assert(bits == 424242);
}
What in your opinion compromises program correctness here? This code works in
2.066 and works as intended by author, reinterpreting memory taken by `bits` as
ulong (as those are binary identical). There is not undefined behavior, no
memory corruption, no bug in application logic. Only issue is the fact that D
type system was not supposed to work in such permissive way.
--
More information about the Digitalmars-d-bugs
mailing list