Fix #5114 - Avoid same-symbol qualifier-difference case falling into DtoCastClass#5117
Fix #5114 - Avoid same-symbol qualifier-difference case falling into DtoCastClass#5117gulugulubing wants to merge 3 commits intoldc-developers:masterfrom
Conversation
thewilsonator
left a comment
There was a problem hiding this comment.
please remove the whitespace changes
OK, is it accpetable: |
| thisptrLval = DtoAllocaDump(DtoCastClass(loc, dthis, iface->type)); | ||
| auto thisVal = DtoLoad(DtoType(thistype), thisptrLval); | ||
| DImValue dthis(thistype, thisVal); | ||
| thisptrLval = DtoAllocaDump(DtoCastClass(loc, &dthis, iface->type)); |
There was a problem hiding this comment.
looks like no change was made here, except for the dangerous-looking change from heap allocated dthis to stack allocated. Possibly use-after-scope. Revert this change?
There was a problem hiding this comment.
Does the original heap allocated dthis cause potential leak-like lifetime?
| // True dynamic interface casts (different interface symbols) are still valid | ||
| // and are covered below. | ||
| // | ||
| // RUN: %ldc -c %s |
There was a problem hiding this comment.
nitpick: line 11 already tests compilation, so you can remove line 10
It is related to #5114. The root cause is the const(I) -> I contract-context conversion always called DtoCastClass, then due to I.isBaseOf(I, ...) return false, the program accidently fall into the DtoDynamicCastInterface which is ObjC-only and ends in unreachable for non-ObjC.
So I added an early guard for same-symbol qualifier-difference case there.
The patch is only in tocall.cpp, while objcgen.cpp and classes.cpp are modified just because of removing trailing blank.