Getting action on your favorite D issues
Paul Backus
snarwin at gmail.com
Sat Jun 6 18:43:43 UTC 2020
On Saturday, 6 June 2020 at 14:02:54 UTC, ag0aep6g wrote:
>
> I had thought about special-casing bool there, precisely
> because of the issue at hand. I almost wrote that only 0 and 1
> are safe values for bool.
>
> I decided against it, because it seems unlikely that creating
> values beyond 1 will be banned in @safe code. It seems more
> likely that the implementation gets changed to treat all
> non-zero values as true. At least that's what I extrapolate
> from Walter's position on void initialization in general (see
> <https://github.com/dlang/dlang.org/pull/2260/files>).
It seems to me like (a) whether void initialization results in
undefined behavior or merely unspecified values, and (b) whether
bool values other than 0 and 1 are considered valid are
independent questions. That is, it would be perfectly consistent
to say that void initialization of int in @safe code is fine,
because every 4-byte bit pattern represents a valid int, but
void-initialization of bool in @safe code is no good, because
many 1-byte bit patterns do not represent valid bools.
More information about the Digitalmars-d
mailing list