Use an undefined variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux