Can we just have struct inheritence already?

Timon Gehr timon.gehr at gmx.ch
Thu Jun 13 11:27:09 UTC 2019


On 13.06.19 02:37, Walter Bright wrote:
> On 6/12/2019 5:18 PM, Timon Gehr wrote:
>> Undefined values are not undefined behavior.
> 
> I think that is the salient point. You're right.
> 
> 
>> However, there are potential problems, based on which properties you 
>> want to assume that strongly pure functions have:
>>
>> int foo()@safe pure{
>>      int x=void;
>>      return x;
>> }
>>
>> Any code that is optimized based on the assumption that `foo()` will 
>> always return the same value will have undefined behavior, including 
>> the possibility of buffer overflows or dangling pointers.
> 
> Optimizing it means caching the returned value. I don't see how that can 
> lead to undefined behavior.

E.g., in principle, an optimizer can end up caching the result of the 
bounds check but not the result of the function call for something like 
a[foo()]+a[foo()]. (The particular example could be more involved, the 
point is that it is possible that the optimizer only partially applies 
the available information.)


More information about the Digitalmars-d mailing list