Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would C++ exception stops function from being inlined?

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 inlining the function?

like image 445
Ralph Zhang Avatar asked Sep 21 '11 03:09

Ralph Zhang


1 Answers

A compiler can refuse to inline for any reason. gcc lists reasons why it might not inline a function, but exception throwing is not among them. Also, the option -Winline will cause the compiler to issue a warning if it can't inline a function that you marked as inline. You can try that and see if you are doing anything to prevent inlining.

like image 92
David Nehme Avatar answered Sep 23 '22 21:09

David Nehme