Would C++ exception stops function from being inlined?

后端 未结 3 2377
你的背包
你的背包 2021-02-19 19:34

Suppose I have a very simple function that I expect the compiler to inline it. But I may need to throw exception on seeing some invalid input, would that stop the compiler from

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 20:17

    I've just run into this situation with MSVC version 19. A function that throws an exception would not get inlined when compiling for x86. If I replace throw with exit(1) or if I compile for x86-64, it gets inlined just fine.

提交回复
热议问题