Visual C++ __forceinline strange behavior
<p>I'm trying to force visual c++ compiler to inline a particular function. I know that <code>inline</code> or <code>__forceinline</code> is just a suggestion. According <a href="https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx" rel="nofollow noreferrer">MSDN</a>, if compiler cannot inline function which is marked using <code>__forceinline</code> keyword then it generates warning:</p>

<blockquote>
  <p>If the compiler cannot inline a function declared with __forceinline,
  it generates a level 1 warning.</p>
</blockquote>

<p>But I have not got such warning. And when I debug my application I see that there is a <code>call &lt;inlined function address&gt;</code> in Disassembly window i.e. my function was not inlined. So how can I check is my function was inlined or not? Does it mean that if no warning was generated then function was inlined and the problem somewhere in other place?</p>

<p>Here is my function:</p>

<pre><code>__forceinline SecByteBlock aes_generate_iv(size_t blockSize)
{
    const int seedSize = 32;
    SecByteBlock rngSeed(seedSize);
    OS_GenerateRandomBlock(false, rngSeed, rngSeed.size());

    RandomPool rngp;
    rngp.IncorporateEntropy(rngSeed, rngSeed.size());

    SecByteBlock aesIV(blockSize);
    rngp.GenerateBlock(aesIV, aesIV.size());

    return aesIV;
}
</code></pre>

<p>Here is circumstances then VC++ cannot inline function (from <a href="https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx" rel="nofollow noreferrer">MSDN</a>):</p>

<ul>
<li>The function or its caller is compiled with /Ob0 (the default option for debug builds).</li>
<li>The function and the caller use different types of exception handling (C++ exception handling in one, structured exception handling in the other).</li>
<li>The function has a variable argument list.</li>
<li>The function uses inline assembly, unless compiled with /Og, /Ox, /O1, or /O2.</li>
<li>The function is recursive and not accompanied by #pragma inline_recursion(on). With the pragma, recursive functions are inlined to a default depth of 16 calls. To reduce the inlining depth, use inline_depth pragma.</li>
<li>The function is virtual and is called virtually. Direct calls to virtual functions can be inlined.</li>
<li>The program takes the address of the function and the call is made via the pointer to the function. Direct calls to functions that have had their address taken can be inlined.</li>
<li>The function is also marked with the naked __declspec modifier.</li>
</ul>