Possible Duplicate:
Is this self initialization valid?
Is this a well-defined C/C++ program or not?
int foo = foo;
int main()
{
}
Would foo be zero-initialized, or is it undefined behaviour?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is an ill-formed C program. In C initializers for objects with static storage duration must be constant expressions. The
fooon the right-hand side is not a constant expression.In C++ it is well-formed and has defined behavior, because of zero-initialization of objects with static storage duration (which takes place before any other initialization).