Conversion from const char * to const std::string &
<p>I think following code should generate an error:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

static void pr(const std::string &amp;aStr)
{
    std::cout &lt;&lt; aStr &lt;&lt; "\n";
}

int main(void)
{
    const char *a = "Hellu";

    pr(a);

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

<p>But gcc 4.1.2 compiles it successuflly.</p>

<p>Is it that the constructor of std::string get in the way, creating an instance of std::string?</p>

<p>I believe it shouldn't, because reference is merely an alias to a variable (in this case, there is no variable of type std::string that the reference is referring to).</p>

<p>Is anybody out there to explain why the code compiles successfully?</p>

<p>Thanks in advance.</p>
