Struct should be invalid after move

burjui bytefu at gmail.com
Tue Nov 27 16:49:59 UTC 2018


On Tuesday, 27 November 2018 at 15:27:19 UTC, Steven 
Schveighoffer wrote:
> You can do a runtime error (with opPostMove included), but I 
> think a compiler error would require full flow analysis, and 
> would have to default to allowing it, as otherwise you will get 
> false errors that are more annoying than the original problem.

A good modern compiler of a statically compiled language has to 
have flow analysis enabled unconditionally. I don't see any 
reason not to enable it in D frontend, except Walter's 
stubbornness. The current situation with D doesn't even make 
sense: with optimizations enabled, the compiler can reject code 
that compiles just fine without them. I find it sad and 
ridiculous at the same time. This happens exactly because 
dataflow analysis is only enabled when optimizations are enabled:

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


More information about the Digitalmars-d mailing list