Let's say we have this code:
inline int func_2 (int a, int b) {
return time() + a * b;
}
int main (void) {
int x = (int (*[])(int, int)){func_1, func_2, func_3}[1](6, 7);
}
Can gcc be somehow tricked to really inline the indirect calls to func_*
?
After compiling the code with -O2
and -O3
, I could still spot a call func_2
instruction in the assembly output.
I know this hairy expression can be converted into a bulky switch
statement with inlined calls for each case, but I prefer the former for its compactness.