Getting action on your favorite D issues
Patrick Schluter
Patrick.Schluter at bbox.fr
Sat Jun 6 15:41:21 UTC 2020
On Saturday, 6 June 2020 at 15:16:06 UTC, ag0aep6g wrote:
> On 06.06.20 16:34, Avrina wrote:
>> [...]
> [...]
>> [...]
>
> I'm not so sure if you really understand what "undefined
> behavior" means.
>
> By saying this:
>
>> [...]
>
> you're defining the behavior of using void initialized values.
> Once you do that, it's not undefined behavior anymore.
>
> But the spec doesn't do that. Instead it says: "If a void
> initialized variable's value is used before it is set, the
> behavior is undefined." That is, the spec explicitly says that
> doing so is not allowed, and that compilers may assume that it
> doesn't happen. Because that's what "undefined behavior" means.
The interesting thing is that the compiler detects that case when
doing lifetime check, which is only enabled when optimizing. So
the issue with the not initialized bool only happens on
unoptimized code.
>
> But Walter agrees with you: Using a void value shouldn't
> actually have undefined behavior; it should just be an
> arbitrary value. Which is why he has an open pull request to
> change the spec:
> https://github.com/dlang/dlang.org/pull/2260
More information about the Digitalmars-d
mailing list