Re:Undefined Behavior in 2017
by eru on Thursday July 06, 2017 @04:15PM
(#14713551)
Yes, for the general problem you want dependent types (or similar).
There are middle grounds, of course: you can let the compiler figure out on its own what it can, and let it insert runtime checks for the other cases.
And add some way for the programmer to declare that eg "warn me if this can't be optimized" or "trust me, this is safe" or even "here's a proof for you".
But in any case, dependent types are possible---undecidability is not a hard barrier here.
There are middle grounds, of course: you can let the compiler figure out on its own what it can, and let it insert runtime checks for the other cases.
And add some way for the programmer to declare that eg "warn me if this can't be optimized" or "trust me, this is safe" or even "here's a proof for you".
But in any case, dependent types are possible---undecidability is not a hard barrier here.