If you could make any changes to D, what would they look like?
Dukc
ajieskola at gmail.com
Thu Oct 28 15:29:21 UTC 2021
On Thursday, 28 October 2021 at 14:49:41 UTC, Paul Backus wrote:
>
> According to the current language spec, the entire program has
> undefined behavior whether or not the result contains pointers.
> Walter has proposed to change this [1], but the proposal has
> not been accepted.
>
> [1]: https://github.com/dlang/dlang.org/pull/2260
Some other change has been made to the spec after that PR was
made. It currently reads:
> 2. Implementation Defined: If a void initialized variable's
> value is used before it is set, its value is implementation
> defined.
> ```d
> void bad()
> {
> int x = void;
> writeln(x); // print implementation defined value
> }
> ```
> 3. Undefined Behavior: If a void initialized variable's value
> is used before it is set, and the value is a reference, pointer
> or an instance of a struct with an invariant, the behavior is
> undefined.
> ```d
> void muchWorse()
> {
> char[] p = void;
> writeln(p); // may result in apocalypse
> }
> ```
More information about the Digitalmars-d
mailing list