C++: avoid optimizing out variable
<p>I have some useful code in constructor or class <code>Valuable</code>. I want be sure it's executed before <code>submain</code>. How can I guarantee that it's not optimized out?</p>

<pre><code>int main()
{
    // Dear compiler, please don't optimize ctor call out!
    Valuable var;

    return submain();
}
</code></pre>

<p>Is local variable enough? Do I need to use <code>static</code>:</p>

<pre><code>static Valuable *v = new Valuable();
delete v;
v = NULL;
</code></pre>

<p>Can I shorten previous to one liner:</p>

<pre><code>delete new Valuable();
</code></pre>
