Violation of type safety in C++ with function declaration of other type?
<p>I am new to C++ and just try out stuff. I stuck with the following code:</p>

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

void t(){
    std::cout &lt;&lt; "func t()" &lt;&lt; std::endl;
}

int main(int argc, char **argv) {
    int t(); //declaration of function
    std::cout &lt;&lt; t() &lt;&lt; std::endl;
}
</code></pre>

<p>The output is "func t()\n6295712". My concern is the random(?) number printed by t().   </p>

<p>My question is: Why is it allowed to declare a function of another return-type (here: int instead of void) without any error? Is this not a violation of type safety because I never defined a function with a return-type "int"?</p>

<p>Used compiler: gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4</p>