Use an undefined variable

pierozanetti piero.corima@gmail.com
Thu Mar 6 18:09:00 GMT 2008


Hi, 
I have a question. This statement is accepted by the g++ compiler (v. 4.1.2,
under linux):

char c = 'a';
string s = s + c;

But the variable s is used before begin defined! Why? It's correct?

The program aborts when the statement is reached.
If we change the above code into:

string s = s + 'a';

the error changes. A segmentation fault is raised.
Can anyone tell me why the code is accepted?
Thanks

Piero Zanetti


-- 
View this message in context: http://www.nabble.com/Use-an-undefined-variable-tp15880213p15880213.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list