Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8811225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:18:36+00:00 2026-06-14T03:18:36+00:00

int test[2] = { 45, test[0] }; int x = (x = 111); cout

  • 0
int test[2] = { 45, test[0] };
int x = (x = 111);
cout << test[0] << " " << test[1] << " " << x << "\n"; // 45 45 111

Are the assignments in the first two lines legal? Visual Studio 2010 compiles and runs it without any errors or warnings but it seems like an odd case that could possibly be undefined, so I wanted to confirm that it is acceptable. Visual Studio does warn me if I do something blatantly reflexive (and presumably undefined) like int x = x; so I’m wondering how these situations it seems to allow are handled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:18:37+00:00Added an answer on June 14, 2026 at 3:18 am

    From the C++ Standard (C++11, but it wasn’t different in C++98/03):

    (§ 3.3.2/1) The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its initializer (if any), […] [ Example:

    int x = 12;
    { int x = x; }
    

    Here the second x is initialized with its own (indeterminate) value. —end example ]

    This applies to user-defined types as well as array-types as well. Notice how the Standard emphasizes that x in the second example is initialised with an indeterminate value. So there is no way to know what value x is initialised with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class test { public: int data; test(int var = 0):data(var){cout<<constructor<<endl;} ~test(){ cout<<destructor<<endl; } test(const
int test = 0; ifstream inFile; inFile.open(hat.txt); inFile >> test; cout << test; I
int test[3] = {1,2,3}; cout<<test[3]<<endl; // this will get a error but int test[3]
int test (int integer ){ int results =0 ; results = 10 - integer;
interface i1{ int test(); } interface i2{ String test(); } class Test implements i1,i2{
I have a small sample function: #define VALUE 0 int test(unsigned char x) {
Exception in thread Thread-2 java.lang.NumberFormatException: For input string: 3 int test = Integer.parseInt(result[0]); This
My C code #include <stdio.h> #include <stdlib.h> #include help.h int test(int x, P *ut)
class test{ int x; public: //public functions getx() and putx() }; void main() {
Say I have a test like: void TestSomething(int someParam) { // Test code }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.