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

  • SEARCH
  • Home
  • 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 953823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:06:46+00:00 2026-05-16T00:06:46+00:00

I have the following code int m[4]={1,2,3,4}, *y; y=m; *y = f(y++); // Expression

  • 0

I have the following code

int m[4]={1,2,3,4}, *y; 
y=m; 
*y = f(y++); // Expression A

My friend told me that Expression A has a well defined behavior but I am not sure whether he is correct.

According to him function f() introduces a sequence point in between and hence the behavior is well defined.

Someone please clarify.

P.S: I know we should not write such code for practical purpose. It is just for the purpose of learning. 🙂

  • 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-16T00:06:46+00:00Added an answer on May 16, 2026 at 12:06 am

    At best, the code in question has unspecified behavior. For the assignment operators, “the order of evaluation of the operands is unspecified” (C99 §6.5.16/4).

    If the left operand is evaluated first, the result of f(y++) will be stored in m[0]. If the right operand is evaluated first, the result will be stored in m[1].

    As for whether the behavior is undefined, the relevant paragraph is:

    Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored (C99 §6.5/2).

    If the left side is evaluated first, then we run afoul of the second sentence because the ordering is:

    1. The value of y is read on the left side to dereference it
    2. The value of y is read on the right side to increment it
    3. There is a sequence point after the evaluation of the arguments to the function (so, the side effect of y++ is complete and y is written to)

    In step 1, the “prior value” of y is read but for a purpose other than “determining the value to be stored.” Thus, the behavior is indeed undefined because one valid evaluation order yields undefined behavior.

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

Sidebar

Related Questions

I have the following code in my controller: public ActionResult Details(int id) { var
I have the following fields: Inventory control (16 byte record) Product ID code (int
If I have the following code: MyType<int> anInstance = new MyType<int>(); Type type =
I have seen the following code: [DefaultValue(100)] [Description(Some descriptive field here)] public int MyProperty{...}
Suppose I have the following C code. unsigned int u = 1234; int i
I have the following code. I constructed an expression tree and I am stuck
I have the following code #include <algorithm> #include <iostream> #include <vector> #include <functional> int
This is driving me nuts. I have the following code that, when a button
Lets say I have the following code: delegate int MyDel (int n); // my
Let's say I have the following code snippet: int i; double value; for(i =

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.