我尝试从gcc 4.9(gcc-arm-none-eabi,-O2)迁移到gcc 7.2。我的代码构建成功,但结果程序比gcc 4.9大。
我做了一些调查,并意识到,xxx"非虚拟thunk的大小。如果在类中定义了重写函数,那么它太大了:
struct IA { virtual void fa() = 0; };
struct IB { virtual void fb() = 0; };
struct C : IA, IB {
void fa() override {}
void fb() override // If I place definition here,
// size of "non virtual thunk to C::fb()" is almost the same, as the function itself
};
// but if I place definition outside the class,
// size of non virtual thunk is about 6-8 bytes, same as in gcc4.9
可能有一个选项阻止这样的内联?