First two exceptions of strict aliasing rule on cppreference.com says:
- AliasedType is (possibly cv-qualified) DynamicType
- AliasedType and DynamicType are both (possibly multi-level, possibly cv-qualified at each level) pointers to the same type T (since C++11)
I don't clearly understand the difference between these cases. For instance:
struct B { virtual ~B() {} };
struct D : B {};
B* b = new D;
reinterpret_cast<D*>(b);
Is the code above suitable for both cases or not?
As far as I see AliasedType
and DynamicType
both are D
(1st case) and they are pointers to same type D
.
If I’m wrong could you provide examples for each separate case and explain the difference more clearly?