Struct should be invalid after move

Paul Backus snarwin at gmail.com
Wed Nov 28 02:54:30 UTC 2018


On Tuesday, 27 November 2018 at 19:28:13 UTC, Steven 
Schveighoffer wrote:
>> void main()
>> {
>>      int* x;
>>      *x = 0;
>> }
>> 
>> This compiles just fine with `dmd x.d`, but emits an error 
>> with `dmd -O x.d`:
>> Error: null dereference in function _Dmain
>
> Note that complete flow analysis is equivalent to the halting 
> problem. So really, you can never get it perfect, and 
> therefore, there are always going to be some things you can't 
> catch. So it's impossible to fulfill that promise in any 
> compiler.

It's possible if you're willing to make the rules strict enough 
that some otherwise-valid programs get rejected--that's what Rust 
does, after all. But for D, that isn't really an option.


More information about the Digitalmars-d mailing list