Are compilers smart enough to detect a no-op function?

Posted by 0x80 on Stack Overflow See other posts from Stack Overflow or by 0x80
Published on 2010-06-06T18:50:42Z Indexed on 2010/06/06 18:52 UTC
Read the original article Hit count: 213

Filed under:

If I write a function like this:

void doMaybeNothing()
{ 
#ifndef IM_LAZY
   doSomething();
#endif
}

Are modern compilers smart enough to detect a no-op function and optimize so that there are no cycles wasted? Or is there always a small performance impact?

© Stack Overflow or respective owner

Related posts about c++