address of local variable
<p>I have a hard time understanding the difference between these three:</p>

<pre><code>const char * f() {
  return "this is a test";
}

const char * g() {
  const char * str = "test again";
  return str;
}

const double * h() {
  const double a = 2.718;
  return &amp;a;
}
</code></pre>

<p>I get a warning for the <code>h()</code>, as <code>warning: address of local variable ‘a’ returned</code>. Which makes sense, but I do not understand why the compiler (<code>gcc -Wall</code>) is ok with the <code>f()</code> and <code>g()</code> function.</p>

<ul>
<li>Isn't there a local variable there?</li>
<li>When and how does the pointer returned by <code>f()</code> or <code>g()</code> gets deallocated?</li>
</ul>
