I am leaning the detail of Trait Object call. And I know Trait Object will carry two things : a data pointer and a vtable . But from here it seems the vtable will never be used at runtime , its sole usage is to retrieve the function pointer in CG stage. So my question is why we carry it at runtime ?
I have no idea about the compiler internals or what the particular code you’ve linked is doing, but the vtable is definitely used at runtime (unless for cases where that usage is optimized away, I guess). Take a look at the assembly output here for example. You see two dynamic calls to two functions with different offset off the vtable pointer that apparently was passed in
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.