Hi,
On 2019-05-21 16:47:50 +0200, Antonin Houska wrote:
> I admit I didn't think about this problem. Nevertheless I imagine that due to
> constness of the variables like TTSOpsVirtual (and due to several other const
> declarations) the compiler might be able to compute the address of the
> tts_ops->clear() expression.
It really can't, without actually fetching tts_ops, and reading the
callback's location. How would e.g. tts_virtual_copyslot() know that the
slot's tts_ops point to TTSOpsVirtual? There's simply no way to express
that in C. If this were a class in C++, the compiler would have decent
chance at it these days (because if it's a final method it can infer
that it has to be, and because whole program optimization allows
devirtualization passes to do so), but well, it's not.
And then there's the whole inlining issue explained in my other recent
mail on the topic.
Greetings,
Andres Freund