When dealing with copy constructor, the compiler can emit an
UncheckedDerivedToBase implicit cast for the CXXConstructorExpr of the
base class. In such case, when trying to copy the src storage location
to its destination, we will fail on the assert checking that location
types are the same.
When copying from derived to base class, it is acceptable to break that
assumption to only copy common fields from the base class.
Note: the provided test crashes the process without the changes made to
copyRecord.
this variable is unused in a non-debug build, can you add (void)compatibleTypes; to suppress the warning?
(Thanks for this patch, have been testing it locally as it fixes crashes we're hitting in nullability)