I don’t know that there is a documented guarantee anywhere that the dynamically allocated shared memory pointer will be aligned to anything larger than the type you specify. In that case, you could do this:
extern __shared__ float4 s[];
That then demonstrably has the necessary alignment, or CUDA is fundamentally broken.
A similar question is here.
I imagine various CUDA examples violate the strict aliasing rule. I’m not a language expert most regards. However I believe you can find more examples in CUDA documentation or blogs of this type of casting. For example I imagine that another one is here. Another example is discussed here. I’ve never worried about it, as long as you respect the requirement for natural alignment on access, as well as of course allocating enough space to begin with.