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 3440758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:28:14+00:00 2026-05-18T08:28:14+00:00

Considering following array and two series of assignments: char charArray[3]; charArray[0]=’a’; charArray[1]=’b’; charArray[2]=’c’; char

  • 0

Considering following array and two series of assignments:

char charArray[3];

charArray[0]='a';
charArray[1]='b';
charArray[2]='c';

char & charRef1=charArray[0];
charRef1='a';
char & charRef2=charArray[1];
charRef2='b';
char & charRef3=charArray[2];
charRef3='c';

Does C++ standard dictate whether these two series of assignments should be implemented identically or differently by the compiler?

  • 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-05-18T08:28:14+00:00Added an answer on May 18, 2026 at 8:28 am

    No, the standard makes no requirements that the implementation details must be the same. 1.9/1:

    The semantic descriptions in this
    International Standard define a
    parameterized nondeterministic
    abstract machine. This International
    Standard places no requirement on the
    structure of conforming
    implementations. In particular, they
    need not copy or emulate the structure
    of the abstract machine. Rather,
    conforming implementations are
    required to emulate (only) the
    observable behavior of the abstract
    machine as explained below.

    So only the “observable behavior” has to be the same. Observable behavior is defined in 1.9/6:

    The observable behavior of the
    abstract machine is its sequence of
    reads and writes to volatile data and
    calls to library I/O functions.

    The exact instructions used to achieve this are not “observable behavior”, and in your example since the array is not volatile, the order of writes isn’t observable either. In fact, unless you use the array later, the writes themselves aren’t observable. It would be legal for the implementation’s optimizer to successfully remove the entire code snippet in one case but not the other, although perhaps surprising that it could manage only one.

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

Sidebar

Related Questions

Considering following struct and template function, does each use of the function with a
Considering the following architecture: a base object 'Entity' a derived object 'Entry:Base' and a
I'm considering the following: I have some data stream which I'd like to protect
The MSDN documentation is (somewhat) clear about the following two facts about GDI Pens:
Considering the following record types: type drCode1Body = {DrCode : byte ; Name :
Considering the following model: USER Long: PK String: firstName String: lastName USER_EXT Long: PK
I have two assemblies A & B. A has existing reference to B and
I am considering writing a mobile application for one of the following mobile platforms:
In the following JQuery UI widget the author has used extend to include two
Considering the following models, knowing a family, how do I select Kids with no

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.