[Issue 19968] @safe code can create invalid bools resulting in memory corruption
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 8 21:25:19 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=19968
Bolpat <qs.il.paperinik at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |qs.il.paperinik at gmail.com
--- Comment #14 from Bolpat <qs.il.paperinik at gmail.com> ---
(In reply to elronnd from comment #13)
> I believe that void initialization of bools should result in their being
> zero-initialized. [...] [S]ince it's as
> cheap to and them with 1 (to get a random result) as to and them with 0
> (which is what mov target, 0 does anyway), zero-initialize them.
It's cheap for a single bool, granted, but consider arrays of bools:
bool[large_num] array = void;
Void init is primarily a thing for static arrays. Silently initializing those
with zeros is basically (performance) code breaking. Note that someone with
writing that code with reasons did that for performance, so it *is* a breaking
change.
--
More information about the Digitalmars-d-bugs
mailing list