what is happening?
The compiler assumes that you know what you're doing, so that the pointer really does point to a D object, and changes the pointer type accordingly, adjusting the value if necessary to point to the complete D object rather than the B sub-object.
If you get it wrong, and use a D* pointer that doesn't really point to a D object, then you'll get undefined behaviour; so be careful.
Is it simply calculating an offset at compile time and applying that offset to the pointer?
Yes.
Or is there something happening at runtime in order to do the cast?
No; "static" implies that it uses only compile-time information. The only runtime activity is adding the fixed offset if necessary.
Use dynamic_cast if you want a runtime check that the conversion is valid (as long as the types are polymorphic). It will give a null pointer (or throw a bad_cast exception if you're casting a reference rather than a pointer) if there isn't really a D object there.
static_castis always resolved using compile-time type info. (This may involve a runtime action). If it's not an appropriate cast you either get a compile error or undefined behaviour. In your snippet it is OK becausebis aD; however ifbwerenew B()then the cast compiles but causes undefined behaviour if run.