I ran into a peculiar... behavior today that I still don't quite understand. I do understand that an "undefined behavior warning" means I'll likely get undefined behavior. What I don't understand is why (in this particular case).
In this example, I am initializing a dyn pointer as null, using transmute. Obviously this is a bad thing to do, and the compiler is within its rights to get upset, but this doesn't really explain what happens next, at least not to me.
When I build this with --release, the compiler inserts an illegal instruction after the first println. Clearly, dereferencing this pointer would result in very bad things happening, but why is it that initializing it generates an illegal instruction in the produced binary? And if this is intentional, then why are we not generating a compile-time error rather than a runtime error?
Is there some aspect of initializing a dyn pointer that I'm overlooking?