If you could make any changes to D, what would they look like?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Oct 27 19:31:52 UTC 2021


On Wed, Oct 27, 2021 at 07:19:31PM +0000, Dukc via Digitalmars-d wrote:
[...]
> ```d
> pure short coming()
> { typeof(return) result = void;
>   return result; //may return anything
> }
> ```
> 
> But when you think of it, why should this be a problem? This one
> returns an implementation defined value. If a compiler skips repeated
> calls to this one because of the `pure` attribute and just reuses the
> value from the first call, so what? Because the return values are
> implementation defined, the compiler is free to have them all to be
> the same with regards to each other.

Returning a void-initialized (i.e., *un*initialized) result invokes UB.
The compiler is free to do (or not do) whatever it wants in this case.


T

-- 
Only boring people get bored. -- JM


More information about the Digitalmars-d mailing list